且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

autolayout之后获取uiview的frame

更新时间:2022-09-14 10:47:38

这个只要一行代码就搞定了。详细请看:

In order to get the right frame/bounds of your UIImageView after resizing, you need first ask auto-layout to update that layout using [yourImageView layoutIfNeeded]. that will solve your constraints and update your yourImage.bounds.

[myImageView layoutIfNeeded];

NSLog(@"w: %f, h: %f", myImageView.bounds.size.width, myImageView.bounds.size.height);

就一行代码啊!

 

或者在这个方法中获取frame:

- (void)viewDidLayoutSubviews {
// VC just laid off its views
}

 

欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!

















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/p/4299896.html,如需转载请自行联系原作者