如何以编程方式布局一个与此完全相同的 UIButton?
我正在使用 setInputAccessoryView 方法添加一个完成按钮,如下图键盘上方所示。然而,该按钮看起来非常难看。因此,我需要您的帮助以编程方式创建相同的按钮(颜色、按钮类型)。
这是我当前的代码:
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
I'm using setInputAccessoryView method to add a done button like in the picture below above the keyboard. However, the button shows up very ugly. So, I need your help to programmatically create the same button (color,button type).
Here's my current code:
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];
Thx for helping,
Stephane
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果那个黑色半透明条是 UIToolBar,那么您应该添加 UIBarButtonItem。初始化函数应该是
initWithBarButtonSystemItem:target:action:
,其中第一个参数是UIBarButtonSystemItemDone
,target
是处理操作和操作的对象。action
它应该执行的选择器。If that black translucent bar is a UIToolBar, then you should add a UIBarButtonItem. The initializer function should be
initWithBarButtonSystemItem:target:action:
where the first parameter isUIBarButtonSystemItemDone
and thetarget
being the object dealing with the action and theaction
the selector that it should execute.