我在界面生成器中添加了一個圖像按鈕,我想使用CGPointMake來定位它,所以我將按鈕IBOutlet添加到.h文件中,然後在.m文件中添加一個CALayer,在這裏是我的代碼...
在.m文件使用CALayer不工作定位按鈕
// This is the .m file
- (void)viewDidLoad
{
CALayer *btn = thebtn.layer;
btn.position = CGPointMake(480, 150);
btn.opacity = 0.4f;
[self.view.layer addSublayer:btn];
}
.h文件中
// This is the .h file
@interface ViewController : UIViewController
{
IBOutlet UIButton *thebtn;
}
所以這是偉大的,但我的問題是,按鈕位置沒有變化,但該鍵不透明度改爲那麼我該如何解決這個問題?
由於提前
是否有任何理由使用圖層而不是視圖? – LuisCien