OK. I have done the Google search, the Stack search, the Wenderlich search (is that a meme yet?). I have tried every thing here on overflow and nothing is working.
I need a CALayer expert.
I have a tableView that I'm showing as a dropdown from the top of my app. It shows up fine and dandy until I try to round the bottom left/right corners. Every attempt I have tried to do this has resulted in my table just disappearing entirely. The methods still fire and I get my completions for the up/down methods. However the table just disappears.
Code with a tableView:
- (void)setupTopMenu {
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
self.topMenuTable = [[UITableView alloc] initWithFrame:CGRectMake((screenWidth / 2) - ((screenWidth - topMenuSideBuffer) / 2), self.view.frame.origin.y + topBuffer, (screenWidth - topMenuSideBuffer), 0) style:UITableViewStylePlain];
self.topMenuTable.backgroundColor = DARK_BLUE_NAVBAR_COLOR;
self.topMenuTable.dataSource = self;
self.topMenuTable.delegate = self;
self.topMenuTable.scrollEnabled = YES;
self.topMenuTable.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.topMenuTable.separatorColor = [UIColor blackColor];
self.topMenuTable.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
self.topMenuTable.layer.borderColor = [UIColor blackColor].CGColor;
self.topMenuTable.layer.borderWidth = 0.4f;
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.topMenuTable.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path = maskPath.CGPath;
self.topMenuTable.layer.mask = maskLayer;
[self.view addSubview:self.topMenuTable];
}
Code with just a view (I thought maybe it had something to do with the tableView but it behaves the same when I use a regular UIView)
- (void)setupTopMenu {
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
self.topMenuView = [[UIView alloc] initWithFrame:CGRectMake((screenWidth / 2) - ((screenWidth - topMenuSideBuffer) / 2), self.view.frame.origin.y + topBuffer, (screenWidth - topMenuSideBuffer), 0)];
self.topMenuView.backgroundColor = [UIColor redColor];
self.topMenuView.layer.borderColor = [UIColor blackColor].CGColor;
self.topMenuView.layer.borderWidth = 0.4f;
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.topMenuView.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path = maskPath.CGPath;
self.topMenuView.layer.mask = maskLayer;
[self.view addSubview:self.topMenuView];
}
Code I'm using to show the view(s):
- (void)showTopMenu {
if (!isTopMenuDown) {
[UIView animateWithDuration:0.45 animations:^ {
//self.topMenuTable.frame = CGRectMake((self.screenWidth / 2) - (self.topMenuWidth / 2), self.view.bounds.origin.y + topBuffer, self.topMenuWidth, self.topMenuHeight);
self.topMenuView.frame = CGRectMake((self.screenWidth / 2) - (self.topMenuWidth / 2), self.view.bounds.origin.y + topBuffer, self.topMenuWidth, self.topMenuHeight);
} completion:^(BOOL finished) {
}];
} else {
[UIView animateWithDuration:0.35 animations:^ {
// self.topMenuTable.frame = CGRectMake((self.screenWidth / 2) - (self.topMenuWidth /2), self.view.bounds.origin.y + topBuffer, self.topMenuWidth, 0);
self.topMenuView.frame = CGRectMake((self.screenWidth / 2) - (self.topMenuWidth /2), self.view.bounds.origin.y + topBuffer, self.topMenuWidth, 0);
} completion:^ (BOOL finished) {
}];
}
isTopMenuDown =! isTopMenuDown;
}
NOTE: I have also tried the idea of adding the mask to the layer like in Round some corners of UIView and round the view’s layer’s border too
Same result.
If I take out the Layer code the views show up perfectly but using the layer code makes them disappear.
Is there something about the way I'm showing the view that I can't see, that is making it disappear?
Thanks for the help.