我正在爲iPad應用程序編程創建按鈕。當我看到按鈕時,它看起來像是一個陰影類型的東西。它是什麼,我如何擺脫它?我的按鈕上有一個陰影
這裏是創建它的代碼:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.titleLabel.font = [UIFont fontWithName:@"Trebuchet MS" size:12];
[myButton setTitle:@"test" forState:UIControlStateNormal];
myButton.frame = CGRectMake(0, 0, self.leftScrollView.frame.size.width, 50);
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gear12.png"]];
[myButton addSubview:myImageView];
[self.leftScrollView addSubview:myButton];
UPDATE:
好吧,我發現我只得到這種效果,當它在我的滾動視圖。如果我將它添加到視圖中,則無陰影效果。
頂部測試按鈕,該按鈕是視圖的子視圖。底部按鈕是scrollview的子視圖,它是視圖的子視圖(按鈕/視圖vs按鈕/滾動視圖/視圖)。
白色部分是視圖,灰色是滾動視圖/視圖。
更新2:
由robmayor指出,UIButtons總是有雙線的效果,只是沒有都明顯時,背景色爲白色。藍色是視圖,灰色是子視圖滾動視圖。
這可能是有用的: http://stackoverflow.com/questions/18341319/how-to-get-rid-of-gap-around-round-rect-button –