backImageView.layer.cornerRadius = backImageView.frame.size.width / 2; backImageView.layer.masksToBounds = YES; frontImageView.layer.cornerRadius = frontImageView.frame.size.width / 2; frontImageView.layer.masksToBounds = YES;
// borderWidth 表示边框的宽度 CGFloat imageW = image.size.width + 2 * borderWidth; CGFloat imageH = imageW; CGSize imageSize = CGSizeMake(imageW, imageH); UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); CGContextRef context = UIGraphicsGetCurrentContext(); // borderColor表示边框的颜色 [borderColor set]; CGFloat bigRadius = imageW * 0.5; CGFloat centerX = bigRadius; CGFloat centerY = bigRadius; CGContextAddArc(context, centerX, centerY, bigRadius, 0, M_PI * 2, 0); CGContextFillPath(context); CGFloat smallRadius = bigRadius - borderWidth; CGContextAddArc(context, centerX, centerY, smallRadius, 0, M_PI * 2, 0); CGContextClip(context); [image drawInRect:CGRectMake(borderWidth, borderWidth, image.frame.size.width, image.frame.size.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);
UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale)
CGContextRef context = UIGraphicsGetCurrentContext();
[borderColor set];
// Sets the fill and stroke colors in the current drawing context
CGFloat bigRadius = imageW * 0.5; CGFloat centerX = bigRadius; CGFloat centerY = bigRadius; CGContextAddArc(context, centerX, centerY, bigRadius, 0, M_PI * 2, 0);
void CGContextAddArc(CGContextRef cg_nullable c, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, int clockwise)
CGContextFillPath(context);
CGFloat smallRadius = bigRadius - borderWidth; CGContextAddArc(context, centerX, centerY, smallRadius, 0, M_PI * 2, 0);
CGContextClip(context);
[image drawInRect:CGRectMake(borderWidth, borderWidth, image.frame.size.width, image.frame.size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有