#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"%f %f %f %f",_btn.frame.origin.x,_btn.frame.origin.y,_btn.frame.size.height,_btn.frame.size.width);
_btn.frame = CGRectMake(20, 20, 280, 280);
NSLog(@"%f %f %f %f",_btn.frame.origin.x,_btn.frame.origin.y,_btn.frame.size.height,_btn.frame.size.width);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
在運行後 輸出結果為:
2014-09-21 15:25:34.779 test[2473:80334] 20.000000 20.000000 30.000000 30.000000
2014-09-21 15:25:34.784 test[2473:80334] 20.000000 20.000000 30.000000 30.000000
Xcode6默認是勾選這兩項的,去掉才能有效.不過,以後屏幕多了,用自動布局來適配屏幕是大勢所趨,再用代碼來適配將會是場噩夢,建議還是習慣用autolayout+sizeclasses適配屏幕