-
內(nèi)邊距 == 切掉設置區(qū)域裳瘪,內(nèi)容顯示在未切區(qū)域
-
以按鈕為例:
![Uploading Snip20150927_36_837649.png . . .]
-
contentEdgeInsets
- 會把UIImageView和UIlabel當做一個整體移動
-
titleEdgeInsets/imageEdgeInsets
- 那么不會影響到另外一個, 也就是只會改變當前設置的這個控件
案例一
- 代碼實現(xiàn):
- (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];
}