autolayout之后获取uiview的frame

简介:

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

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: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!http://www.cnblogs.com/sunshine-anycall/p/4299896.html
相关文章
|
iOS开发
iOS 开发 - tableView内嵌scrollView时,在plus上滑动scrollView时和tableView有冲突
iOS 开发 - tableView内嵌scrollView时,在plus上滑动scrollView时和tableView有冲突
132 0
|
iOS开发
iOS UITableViewCell嵌套CollectionView,tableview和collectionview同时滑动bug修复
iOS UITableViewCell嵌套CollectionView,tableview和collectionview同时滑动bug修复
919 0
|
UED 缓存 异构计算
UIImageView添加圆角的几种方法
喜欢我的可以关注收藏我的个人博客:RobberJJ 创建一个UIImageView对象: UIImageView * poImgView = [[UIImageView alloc] init]; 第一种方法 poImgView.
943 0
|
iOS开发 Swift
iOS编程(双语版)-视图-Frame/Bounds/Center
1. Frame 每个视图都有一个frame属性,它是CGRect结构,它描述了视图所在的矩形在其父视图中的位置。 (屏幕坐标系默认的原点在左上角,x轴向右伸展,y轴向下伸展) 设置frame通常通过视图的指定初始化器initWithFrame 下面来看个例子,该例子初始化了3个相互叠加的矩...
1032 0