问题描述
我使用iOS 10 Beta 7和Xcode 8 beta测试了我的应用程序,一切正常。然而就在几分钟前,我安装了两个现在可用的GM版本并面临一个奇怪的问题。
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.
我在我的应用程序和我的自定义中使用自定义表视图单元格我正在使用 cornerRadius
和 clipsToBounds
来创建圆形视图。
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;
}
这看起来还不错,然而在新GM发布的所有观点中都有圆角消失了。这发生在 UIView
, UILabels
和 UIButtons
。
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.
推荐答案
我不确定这是不是一个新的要求,但我通过在做任何 cornerRadius
之前添加 [self layoutIfNeeded];
来解决这个问题。所以我的新自定义 awakeFromNib
如下所示:
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.
这篇关于带有xcode 8 GM的iOS 10 GM导致视图因roundCorners&而消失。 clipsToBounds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!