I tested my app with iOS 10 Beta 7 and Xcode 8 beta and everything worked fine. However just a few minutes ago I installed the now available GM releases of both and faced a weird issue.
I am using custom table view cells in my app and in my custom cell's I am using cornerRadius
and clipsToBounds
to create rounded views.
- (void)awakeFromNib { [super awakeFromNib]; self.tag2label.layer.cornerRadius=self.tag2label.frame.size.height/2; self.tag2label.clipsToBounds=YES; }
This looked okay before however in the new GM releases all the views which had the rounded corners disappeared. This happened to UIView
, UILabels
and UIButtons
.
I solved this below.
I am not sure if this is a new requirement, but I solved this by adding [self layoutIfNeeded];
before doing any cornerRadius
stuff. So my new custom awakeFromNib
looks like this:
- (void)awakeFromNib { [super awakeFromNib]; [self layoutIfNeeded]; self.tag2label.layer.cornerRadius=self.tag2label.frame.size.height/2; self.tag2label.clipsToBounds=YES; }
Now they all appear fine.
To fix invisible views with cornerRadius=height/2 create category UIView+LayoutFix
In file UIView+LayoutFix.m add code:
- (void)awakeFromNib { [super awakeFromNib]; [self layoutIfNeeded]; }
add category to YourProject.PCH file.
It will works only if you used [super awakeFromNib] in your views :
MyView.m
- (void)awakeFromNib { [super awakeFromNib]; ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With