需要專家的幫助如何在iOS UIButton中添加陰影?
我在製作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;
}
現在我想申請,陰影,在Adobe Photoshop看到這個圖片的屬性,
我怎麼能這樣做使用核芯顯卡或iOS庫的任何核心基礎?
的Adobe的陰影看起來如下
可以顯示其中包含陰影其中鍵入您需要 –
任何圖像層陰影,你可以看到許多的圖像輸出在特定的角度。 –