iOS

iOS -- 内边距 contentInset

2015-11-12  本文已影响11308人  iOS_成才录
案例一
Snip20151025_9.png
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"024"] forState:UIControlStateNormal];
    [btn setTitle:@"贵宾" forState:UIControlStateNormal];
    btn.frame = CGRectMake(100, 100, 145, 60);
    
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    btn.backgroundColor = [UIColor redColor];
    btn.imageView.backgroundColor = [UIColor greenColor];
    btn.titleLabel.backgroundColor = [UIColor yellowColor];
    
    // 上左下右
    btn.contentEdgeInsets = UIEdgeInsetsMake(20, 0, 0, 0);
    btn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
//    btn.imageEdgeInsets = UIEdgeInsetsMake(50, 0, 0, 00);
    
    [self.view addSubview:btn];
}
上一篇 下一篇

猜你喜欢

热点阅读