0
我嘗試過改變UIActionSheet
的背景顏色像一個按鈕,點擊裏面以下,更改UIActionSheet iOS的背景顏色?
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Unfollow"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Unfollow"
otherButtonTitles:nil];
[actionSheet showInView:self.parent.view];
CGSize mySize = actionSheet.bounds.size;
CGRect myRect = CGRectMake(0, 0, mySize.width, mySize.height);
UIImageView *redView = [[UIImageView alloc] initWithFrame:myRect];
[redView setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5]];
[actionSheet insertSubview:redView atIndex:0];
但我沒有改變背景顏色。我從stackoverflow得到這個。而且我試圖用代理方法做到這一點,
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet{
UIImage *theImage = [UIImage imageNamed:@"crownImg"];
theImage = [theImage stretchableImageWithLeftCapWidth:32 topCapHeight:32];
CGSize theSize = actionSheet.frame.size;
// draw the background image and replace layer content
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[actionSheet layer] setContents:(id)theImage.CGImage];
}
這也沒有給出預期的輸出。有沒有辦法改變UIActionSheet
的背景顏色?
我做過'yourActionSheet.delegate = self; yourActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;'在按鈕點擊。可以嗎?但我仍然有這個問題。 – codebot
沒有人,你在那個地方創建UIActionsheet你需要添加行,等待 –
我在按鈕點擊方法內創建操作表 – codebot