【发布时间】:2013-02-23 19:31:08
【问题描述】:
我正在尝试从另一个类更改UIButton 的alpha。在设置我的 UIButton 的 alpha 属性中调用的函数实际上被调用了,因为我在那里放了一个 NSLog 并且我可以看到它是如何工作的。如果您能给我任何建议,我将不胜感激。
这是我当前的代码。
ViewController.h
- (void) setAlphaToButton;
@property (strong, nonatomic) IBOutlet UIButton *myButton;
ViewController.m
@synthesize myButton;
- (void) setAlphaToButton {
myButton.alpha = 0.5;
NSLog(@"Alpha set");
}
ImageViewSubclass.m
- (void) tapDetected:(UITapGestureRecognizer *)tapRecognizer {
ViewController *VC = [[ViewController alloc] init];
[VC setAlphaToButton];
}
当按下图像视图时,在我的控制台中我得到:Alpha set。而且按钮没有变化。
【问题讨论】:
-
你的问题是? 50% 的透明度不起作用?它是完全出现还是根本不出现?您是在调试器中还是在 nslog 的帮助下检查了 alpha 值?您是否尝试过其他值,例如 0 或 0.3f?
-
按钮显示时 alpha 设置为 1.0,因此它根本不会改变其状态。
标签: ios objective-c uiviewcontroller uibutton alpha