u014207420
小蚂蚁威小威
2014-09-21 07:34

Xcode 6 我用代码改变storyboard的控件的frame值为何无法成功,菜鸟新手求大神指点

  • oc
  • xcode
  • ios
  • frame
  • uibutton
#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
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答