Ios6 在ios中为uibutton setimage设置alpha值?
我尝试使用以下代码设置按钮图像中的alpha值:Ios6 在ios中为uibutton setimage设置alpha值?,ios6,uiimageview,uibutton,alpha,Ios6,Uiimageview,Uibutton,Alpha,我尝试使用以下代码设置按钮图像中的alpha值: UIImageView *imageTopView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"Top_80.png"]]; imageTopView.alpha = 0.5; topBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [topBtn addTarget:self action:@sele
UIImageView *imageTopView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"Top_80.png"]];
imageTopView.alpha = 0.5;
topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[topBtn addTarget:self action:@selector(btnRotatingObj:)
forControlEvents:UIControlEventTouchUpInside];
[topBtn setImage: imageTopView.image forState:UIControlStateNormal];
[topBtn setTitle:@"TOP" forState:UIControlStateNormal];
[self.view addSubview:topBtn];
它不工作….您正在使用图像视图的图像设置按钮的图像。图像视图的alpha值为0.5,但当然不是图像 而是将图像视图添加为按钮的子视图:
[topBtn addSubView:imageTopView];