我想知道我怎么可以创建自定义的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. 如何创建一个自定义NSMenuItem
- 4. 我将如何创建一个自定义的GWT CellTable类?
- 5. 创建一个jQuery插件,我如何做自定义范围?
- 6. 如何创建自定义UIButton(带图像)但仍使用setTitle?
- 7. 我如何创建自定义控件?
- 8. 如何创建自定义)
- 9. 创建一个自定义的UITableViewCell
- 10. 创建一个自定义的BufferedImage
- 11. 创建一个自定义的UITableView
- 12. 创建一个自定义的sys.stdout类?
- 13. Grails - 创建一个自定义的PersistenceEventListener
- 14. 突出显示一个自定义UIButton
- 15. 如何创建一个像Facebook一样的自定义按钮?
- 16. iPhone应用程序。创建一个包含UITextField和UIButton的自定义UIView
- 17. 我如何创建一个自定义ListView与我的XML布局文件?
- 18. 如何创建一个自定义URI到自定义标签(taglib)
- 19. 创建一个自定义依赖块
- 20. 创建一个WPF自定义控件
- 21. 创建一个自定义datagridrowview
- 22. 为ASP.Net创建一个自定义PrincipalPermission
- 23. Android:如何创建一个自定义视图的ContextMenu
- 24. 如何创建一个不使用i18n的自定义VagrantError类?
- 25. 如何创建一个更好看的自定义测量场?
- 26. 如何创建一个自定义的C#异常?
- 27. Android - 如何创建一个自定义(不同)的微调框
- 28. 如何在Wix中创建一个空的自定义表格?
- 29. 如何在UITableViewController中创建一个自定义的UIToolbar组件?
- 30. 如何为Eclipse创建一个自定义的“新类向导”?
从您添加的图片中,我很难理解您在自定义UIButton中查找的自定义功能。你想要什么?自定义颜色,字体或图像?因为所有这些都可以在没有继承UIButton的情况下实现。 –
http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/ – 0x8badf00d
我想添加7 UILabel与他们的价值在右上方和容器与这种风格? – GoldFire