简体   繁体   English

具有自动布局的UIButton不会出现在Xcode 8中

[英]UIButton with autolayout doesn't appear in Xcode 8

I updated Xcode from 7.1.1 to 8 just before and found that UIButton is not appearing. 我将Xcode从7.1.1更新到了之前的8,发现没有出现UIButton Before updating Xcode it worked well. 在更新Xcode之前,它运行良好。 I am using autolayout and tried to make round button. 我正在使用自动autolayout并尝试制作圆形按钮。

My Code 我的密码

btn.layer.masksToBounds = YES;
btn.layer.cornerRadius = btn.frame.size.height/2;

I tried this code, but not working for me 我尝试了这段代码,但对我不起作用

[self.view layoutIfNeeded];

Even I confirmed the button is visible in the Debug View Hierarchy. 即使我确认该按钮在“调试视图层次结构”中也是可见的。

Below I attached debug view hierarchy. 下面我附加了调试视图层次结构。

UIButton appears in Debug View Hierarchy UIButton出现在“调试视图层次结构”中

I just solved this issue. 我刚刚解决了这个问题。

I moved those code from viewDidLoad to viewDidAppear and it works fine. 我将这些代码从viewDidLoad移到了viewDidAppear,并且工作正常。

btn.layer.masksToBounds = YES;
btn.layer.cornerRadius = btn.frame.size.height/2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM