gpt4 book ai didi

iPhone开发: How to create colored or translucent background for UIActionSheet?

转载 作者:行者123 更新时间:2023-12-03 18:31:05 26 4
gpt4 key购买 nike

当您尝试在 iPhone 的“便笺”应用程序中删除便笺时,会弹出 UIActionSheet。该片材是半透明的(但不是黑色半透明的)。这是如何实现的?是否可以将UIActionSheet的背景设置为某种颜色?

最佳答案

我通常实现以下委托(delegate)方法:

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet

只是为了制作一个样本。在本例中,我使用拉伸(stretch)的 png 作为背景:

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
UIImage *theImage = [UIImage imageNamed:@"detail_menu_bg.png"];
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];
}

这是结果: alt text http://grab.by/4yF1

关于iPhone开发: How to create colored or translucent background for UIActionSheet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1181272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com