首页 > 其他 > 详细

离屏渲染

时间:2017-12-14 12:25:34      阅读:184      评论:0      收藏:0      [点我收藏+]

1、圆角使用UIImageView装载一个圆角图片来处理。

@implementation UIImage (RoundedCorner) 

- (UIImage *)imageWithRoundedCornersAndSize:(CGSize)sizeToFit andCornerRadius:(CGFloat)radius

{

   CGRect rect = (CGRect){0.f, 0.f, sizeToFit};

   UIGraphicsBeginImageContextWithOptions(sizeToFit, NO, UIScreen.mainScreen.scale); CGContextAddPath(UIGraphicsGetCurrentContext(), [UIBezierPath bezierPathWithRoundedRect:re ct cornerRadius:radius].CGPath); CGContextClip(UIGraphicsGetCurrentContext()); [self drawInRect:rect]; UIImage *output = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext();

    [self drawInRect:rect];

   UIImage *output = UIGraphicsGetImageFromCurrentImageContext();

   UIGraphicsEndImageContext();

   return output;

}@end

2、设置阴影

  CALayer *shadowLayer = [CALayer layer];

  shadowLayer = [UIColor blackColor].CGColor;

  shadowLayer.shadowOpacity = 1.0;

  shadowLayer.shadowRadius = 4.0;

  shadowLayer.shadowOffset = CGSizeMake(4.0, 4.0); 

 以上可以使用shadowPath来解决,比如:
 shadowLayer.shadowPath = CGPathCreateWithRect(shadowLayer.bounds, NULL);
  开发过程中最好不要让view透明。

离屏渲染

原文:http://www.cnblogs.com/yang99/p/8036978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!