gpt4 book ai didi

iphone - 需要帮助在 iOS4 中的 uiview 中向图像添加阴影吗?

转载 作者:行者123 更新时间:2023-12-03 20:00:48 24 4
gpt4 key购买 nike

我正在尝试为图像创建阴影。我在 View 之间也有一个动画,这是背景。但是,当我使用以下代码时,不会绘制图像。大家有什么想法吗?

self.frontViewBackground = [[[UIView alloc] initWithFrame:frame] autorelease];
//self.frontViewBackground.image = [UIImage imageNamed:@"whitepaper3.png"];
self.frontViewBackground.multipleTouchEnabled = YES;
[self.photoView addSubview:self.frontViewBackground];

UIImage *image = [UIImage imageNamed:@"whitepaper3.png"];

CGContextRef ctx = UIGraphicsGetCurrentContext();

CGContextSetShadow(ctx, CGSizeMake(1, -2), 3.0);
[image drawInRect:self.frontViewBackground.frame blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRestoreGState(ctx);

最佳答案

您是否考虑过使用 CALayer 的影子属性?例如,您可以执行以下操作:

UIView *view = [[UIView alloc] initWithFrame:frame];
view.layer.shadowColor = [[UIColor blackColor] CGColor];
view.layer.shadowRadius = 5.0

在此处查看更多信息:http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowColor

关于iphone - 需要帮助在 iOS4 中的 uiview 中向图像添加阴影吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3539971/

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