Sam*_*ikh 1 uibutton dropshadow ios
需要专家的帮助
我正在制作 UIButton 自定义,我正在裁剪背景并在 UIButton 上显示如下。
[self setBackgroundImage:[self getSingleColorImageForLinear:self.frame] forState:UIControlStateSelected];
//Method to make take image
-(UIImage *)getSingleColorImageForLinear:(CGRect)frame{
CGSize size = CGSizeMake(frame.size.width,frame.size.height);
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
size_t gradientNumberOfLocations = 1;
CGFloat gradientLocations[1] = { 0.0 };
CGFloat gradientComponents[4] = { 0, 0, 0, 0.3, };
CGGradientRef gradient = CGGradientCreateWithColorComponents (colorspace, gradientComponents, gradientLocations, gradientNumberOfLocations);
CGContextDrawLinearGradient(context, gradient, CGPointMake(0, 0), CGPointMake(0, size.height), 0);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGGradientRelease(gradient);
CGColorSpaceRelease(colorspace);
UIGraphicsEndImageContext();
return image;
}
Run Code Online (Sandbox Code Playgroud)
现在我想应用,在 Adobe Photoshop 中看到的投影属性到这个图像,
我如何使用 Core Graphics 或 iOS 库的任何 Core Foundation 来做到这一点?
Adobe 的投影如下所示
button.layer.shadowColor = [UIColor blackColor].CGColor;
button.layer.shadowOffset = CGSizeMake(5, 5);
button.layer.shadowRadius = 5;
button.layer.shadowOpacity = 0.5;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4240 次 |
| 最近记录: |