iOS 如何获取自动布局中控件的适配后的真实Frame guoshengboy 2017-12-14 1,105 阅读1分钟 //xib获取控件适配后的真实frame -(void)layoutSubviews { [super layoutSubviews]; // 不加这下面两句,获得的尺寸会是xib里的未完成autolayout适配时的尺寸,storyboard同理(把这两句写在viewDidLoad:方法中,将contentView换成控制器的view) [self.contentView setNeedsLayout]; [self.contentView layoutIfNeeded]; }