objective-c - OC里面对控件不能同时改变尺寸和位置吗?
ringa_lee
ringa_lee 2017-04-24 09:13:43
0
1
397
//
//  ViewController.m
//  02计算器
//
//  Created by mac on 15/8/27.
//  Copyright (c) 2015年 xujianxing. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *bg;
- (IBAction)up;
- (IBAction)down;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)up {
    
    NSLog(@"上xx");
    
  CGRect frame=   self.bg.frame;
    frame.size.height=200;
    frame.size.width=200;
    frame.origin.y=frame.origin.y-10;
    self.bg.frame=frame;
    NSLog(@"%f",self.bg.frame.size.height);
}

- (IBAction)down {
    
CGRect  frame = self.bg.frame;
    
    frame.origin.y=frame.origin.y+10;
    self.bg.frame=frame;
}
@end

只变一种就是好的,同时变好像两个都不行了。。打印没有任何变化。。

ringa_lee
ringa_lee

ringa_lee

全部回复(1)
伊谢尔伦

这是因为autolayout导致的,去掉就好了。点击view,取消 auto layout。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板