我想知道我怎麼可以創建自定義的UIButton用的UILabel內像這樣我如何創建一個自定義的UIButton?
-1
A
回答
0
看看這個教程CIMGF Fun with UIButtons and core animation layers
或者:IphoneDevelopment: Programmatic gradient buttons
你基本上只是創建您的UIButton的子類實施定製圖紙。 然後你可以做任何你想要的。這兩個教程可以幫助您創建您想要的樣式,請記住,如果您不想過多地使用圖形代碼,也可以使用圖像。
0
你可以這樣做:
int i=0;
UIButton *customButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
//Set the height of your button, that will depend on how much text you will be putting
//inside
[customButton setFrame:CGRectMake(3,40,315,130)];
for(i=0; i<7; i++){
//Their position will change depending on which label you are adding
UILabel *leftLabel=[[UILabel alloc] initWithFrame:CGRectMake(5, 5+(17*i), 150, 12)];
UILabel *rightLabel=[[UILabel alloc] initWithFrame:CGRectMake(160, 5+(17*i), 150, 12)];
//Set the text for each label
[leftLabel setText:[NSString stringWithFormat:@"Left %d",i+1]];
[rightLabel setText:[NSString stringWithFormat:@"Right %d",i+1]];
//Set the backgroudn as clear to be able to see the background of your button
[leftLabel setBackgroundColor:[UIColor clearColor]];
[rightLabel setBackgroundColor:[UIColor clearColor]];
//Add those labels
[customButton addSubview:leftLabel];
[customButton addSubview:rightLabel];
//Do your memory management
[leftLabel release];
[rightLabel release];
}
的CIMGF鏈接會爲你的風格的工作需要。
相關問題
- 1. 如何在UIAlertView中創建一個自定義的UIButton
- 2. 創建自定義的UIButton類
- 3. 用刪除函數創建一個自定義的UIButton類
- 4. 如何創建一個自定義NSMenuItem
- 5. 繼承UIButton以創建自定義按鈕的任何一點?
- 6. 我將如何創建一個自定義的GWT CellTable類?
- 7. 我如何創建一個自定義的UITableViewCell?
- 8. 我如何創建一個自定義傑克遜映射器?
- 9. 如何爲自定義UIButton類創建構造函數?
- 10. 如何使用代碼爲UIButton創建自定義圖像?
- 11. 如何創建自定義UIButton(帶圖像)但仍使用setTitle?
- 12. 我如何創建自定義日期?
- 13. 我如何創建自定義控件?
- 14. 創建一個UIButton
- 15. 如何自定義一個UIView有兩個UIButton的
- 16. 如何創建自定義)
- 17. 創建一個自定義的sys.stdout類?
- 18. 創建一個自定義的UITableView
- 19. 創建一個自定義的UITableViewCell
- 20. 創建一個自定義的BufferedImage
- 21. Grails - 創建一個自定義的PersistenceEventListener
- 22. Django的 - 創建一個自定義ID
- 23. 創建一個自定義的網格
- 24. 創建一個自定義DataGrid的ItemsSource
- 25. 創建一個自定義的UIScrollView Scroller
- 26. 自定義UIButton
- 27. 如何刪除多個UIButton或特定的UIButton動態創建?
- 28. 如何創建一個像Facebook一樣的自定義按鈕?
- 29. 突出顯示一個自定義UIButton
- 30. 我如何創建一個自定義ListView與我的XML佈局文件?
從您添加的圖片中,我很難理解您在自定義UIButton中查找的自定義功能。你想要什麼?自定義顏色,字體或圖像?因爲所有這些都可以在沒有繼承UIButton的情況下實現。 –
http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/ – 0x8badf00d
我想添加7 UILabel與他們的價值在右上方和容器與這種風格? – GoldFire