如何以编程方式布局UIButton完全像这个?

时间:2011-10-20 01:12:54

标签: iphone ios ios4 uiview uibutton

我正在使用setInputAccessoryView方法添加完成按钮,如下图中键盘上方所示。但是,按钮显示非常难看。所以,我需要你的帮助以编程方式创建相同的按钮(颜色,按钮类型)。

enter image description here

这是我目前的代码:

btDone = [[UIButton alloc] initWithType:UIButtonTypeRoundedRect];
[btDone setFrame:CGRectMake(85.0f,0.0f,80.0f,40.0f)];
[btDone setTitle:@"Done"];
[btDone setTitleColor:whiteColor];
[btDone setBackgroundColor:blueColor];

求助,

的Stephane

1 个答案:

答案 0 :(得分:3)

如果黑色半透明条是UIToolBar,那么你应该添加一个UIBarButtonItem。初始化函数应该是initWithBarButtonSystemItem:target:action:,其中第一个参数是UIBarButtonSystemItemDonetarget是处理操作的对象,而action是它应该执行的选择器。