2012-01-31 56 views
2

什么是最好的方式来达到有测试显示为正常的颜色,但没有有效地显示Rect按钮线,使其透明。在iOS 5透明UIButton sdk

我试过alpha设置,但没有运气,因为它使整个按钮和文本透明,这不是我想要的,我宁愿通过UIButton而不是图像实现这一点。

与图像我努力在视图之间链接动作/插座,并发现使用cntrl按钮进行连接并与视图链接更容易。

任何工作的想法是好的

回答

4

尝试创建一个自定义按钮:

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

我相信你的意思是你的第一行代码是:'的UIButton *干训局= [UIButton的buttonWithType:UIButtonTypeCustom] ;'不是四舍五入的类型。 – NJones 2012-01-31 19:48:55

+0

是的,这正是我想要写的。 – 2012-01-31 20:17:33

+0

通过按照实际的方式按钮,它可以像标准按钮一样连接插座和操作?还有代码中的哪一部分(对不起,我对ios有点新鲜)im猜测在viewDidLoad下的实现文件中? – codejunkie 2012-02-02 18:52:20