0
A
回答
1
UIButton *playButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0);
[playButton setTitle:@"Play" forState:UIControlStateNormal];
playButton.backgroundColor = [UIColor clearColor];
[playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"];
UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"];
UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted];
[playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:playButton];
來源:http://jainmarket.blogspot.com/2009/04/create-uibuttonbutton-with-images.html
相關問題
- 1. UIButton image invisible
- 2. UIButton image not resizing - Swift
- 3. UIButton Frame Not Resizing with Image
- 4. iphone image resizing
- 5. UITextView BackGround image iphone
- 6. iPhone image問題
- 7. iphone sdk:UIScrollView as Image
- 8. iphone - image loading
- 9. iPhone Splash Image
- 10. iPhone開發 - IBAction爲和@property
- 11. iphone - 試圖瞭解@property
- 12. iphone @property(retain),init()和標準
- 13. iphone -warning @property(nonatomic,retain)UISegmentedControl * colorChooser;
- 14. iphone - performSelectorInBackground image加載
- 15. iPhone Image Zoom動畫
- 16. iphone image loading問題
- 17. 自定義UIButton iphone
- 18. iphone的UIButton釋放
- 19. iPhone - 的UIButton - 殘障
- 20. iphone 6 vs iphone 5 image命名約定
- 21. NSTimer change image iPhone編程
- 22. iphone image旋轉木馬
- 23. 圖片社交meta標籤 - property =「og:image」name =「twitter:image」itemprop =「image」
- 24. UIPopOver來自UIButton for iPhone
- 25. iPhone UIButton翻轉和展開
- 26. iPhone UIButton自定義動畫
- 27. Iphone UIButton背景顏色
- 28. 在iPhone上切換UIButton
- 29. iPhone:我們對一個UIButton
- 30. Iphone的自定義UIButton