你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS總結_實現UIButton的圖文混排(二)

IOS總結_實現UIButton的圖文混排(二)

編輯:IOS開發綜合

很久沒有寫博客了,之前寫過一篇關於UIButton圖文混排的,但是有點復雜,今天來一個比較簡單地,相信大家回用得著


UIButton *button=[[UIButton alloc] initWithFrame:CGRectMake(60, 90, 100, 40)];

//加文字

[button setTitle:@"描述文字" forState:UIControlStateNormal];

[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

//加圖片

[button setImage:[UIImage imageNamed:@"pulldown"] forState:UIControlStateNormal];

//加邊框

button.layer.borderColor=[UIColor redColor].CGColor;

button.layer.borderWidth=0.5;


這就是不改變位置的情況下混排的效果,根據大家不同的需要大家肯定會改變其位置

\

<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+CiAgICAvL7jEseTNvM7EzrvWwyDX89PSsqLFxTwvcD4KPHA+CiAgICBidXR0b24udGl0bGVFZGdlSW5zZXRzPVVJRWRnZUluc2V0c01ha2UoMCwKIC1idXR0b24uaW1hZ2VWaWV3LmZyYW1lLnNpemUud2lkdGgsCjAsIGJ1dHRvbi5pbWFnZVZpZXcuZnJhbWUuc2l6ZS53aWR0aCk7PC9wPgo8cD4KICAgIGJ1dHRvbi5pbWFnZUVkZ2VJbnNldHM9VUlFZGdlSW5zZXRzTWFrZSgwLAogYnV0dG9uLnRpdGxlTGFiZWwuZnJhbWUuc2l6ZS53aWR0aCYjNDM7NSwKMCwgMCk7PC9wPgo8cD4KICAgIDxpbWcgc3JjPQ=="/uploadfile/Collfiles/20141114/2014111409064283.png" alt="">


說明:EdgeInsets的位置是相對改變的,具體大家可以更具代碼去理解


[self.view addSubview:button];


  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved