iphone - 带边框的透明按钮

标签 iphone ios objective-c uibutton transparency

我试图通过使按钮透明但仍带有边框的按钮来获得这种效果。当我制作透明图像时,由于某种原因,它们会使按钮变大。这是一些效果的例子。



在第一个图像中,导航栏上的按钮对导航栏的背景是半透明的。

在左侧的第二个图像中,“Action Composer”按钮是透明的,但仍带有边框。

最佳答案

试试这个:

这将创建一个透明按钮:

UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame  GRectMake(x, y, w, h);
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button" forState:UIControlStateNormal];
button.backgroundColor=[UIColor clearColor];
[button setTitleColor:[UIColor colorWithRed:0.3 green:0.1 blue:0.4 alpha:1.0] forState:UIControlStateNormal];
[self.view addSubview:btn];

现在边界:
[[button layer] setBorderWidth:2.0f];
[[button layer] setBorderColor:[UIColor greenColor].CGColor];

关于iphone - 带边框的透明按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14585749/

相关文章:

iphone - 清除 NSArrays 的 NSDictionary

objective-c - 以编程方式创建 Cocoa 单选按钮

ios - UITableViewCell 自动高度基于 UILabel 文本的数量

android - 如何停止 watchPosition() 位置检索超时错误?

iphone - 为 OBShapedButton 的(自定义形状按钮)图像着色并重新设置

ios - 如何获取已购买的 iOS IAP Auto Renewable 产品的详细信息

ios - Revmob 广告只显示一次

iphone - 将 UINavigationController 添加到现有的 UIViewController

iphone - JSON响应编码问题

没有 GMT 偏移量的 IOS 时区缩写。需要直接像IST,EST等