Unity3D4.6 UIButton怎么修改Button背景颜色?

Unity3D4.6 UIButton怎么修改Button背景颜色?,第1张

UIButton touristBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, 5, 120, 25)];
[touristBtn setBackgroundColor:[UIColor clearColor]];
[touristBtn setImage:[UIImage imageNamed:@"firstBtnpng"] forState:UIControlStateNormal];
[touristBtn setImage:[UIImage imageNamed:@"secondBtnpng" forState:UIControlStateSelected];
[touristBtn addTarget:self action:@selector(touristEvent:) forControlEvents:UIControlEventTouchUpInside];
[tabView addSubview:touristBtn];
在button的action方法中改变button的状态:

-(void)touristEvent:(id)sender{
UIButton button = (UIButton )sender;
buttonselected = !buttonselected;
}

谢谢。
不过其实我的是类似合图的:因此要用ugui中设置texture
type为sprite(2d
and
ui),这样才能有sprite
mode为mutiple来进行切图。
不知道对于这种方式黑色背景的素材如何转变成透明的背景的。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/13396832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-28
下一篇 2023-07-28

发表评论

登录后才能评论

评论列表(0条)

保存