欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

iOS設置圓角的方法有哪些

這篇文章主要為大家展示了“iOS設置圓角的方法有哪些”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“iOS設置圓角的方法有哪些”這篇文章吧。

在愛輝等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供網(wǎng)站建設、網(wǎng)站設計 網(wǎng)站設計制作定制設計,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,品牌網(wǎng)站設計,成都全網(wǎng)營銷推廣,外貿(mào)營銷網(wǎng)站建設,愛輝網(wǎng)站建設費用合理。

第一種方法:通過設置layer的屬性

最簡單的一種,但是很影響性能,一般在正常的開發(fā)中使用很少.

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
//只需要設置layer層的兩個屬性
//設置圓角
imageView.layer.cornerRadius = imageView.frame.size.width / 2;
//將多余的部分切掉
imageView.layer.masksToBounds = YES;
[self.view addSubview:imageView];

第二種方法:使用貝塞爾曲線UIBezierPath和Core Graphics框架畫出一個圓角

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
 imageView.image = [UIImage imageNamed:@"1"];
 //開始對imageView進行畫圖
 UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0);
 //使用貝塞爾曲線畫出一個圓形圖
 [[UIBezierPath bezierPathWithRoundedRect:imageView.bounds cornerRadius:imageView.frame.size.width] addClip];
 [imageView drawRect:imageView.bounds];
 imageView.image = UIGraphicsGetImageFromCurrentImageContext();
 //結(jié)束畫圖
 UIGraphicsEndImageContext();
 [self.view addSubview:imageView];

第三種方法:使用CAShapeLayer和UIBezierPath設置圓角

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
  
  [super viewDidLoad];
  
  UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 100)];
  imageView.image = [UIImage imageNamed:@"1"];
  UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(25, 5)];
  CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
  maskLayer.frame = imageView.bounds;
  maskLayer.path = maskPath.CGPath;
  imageView.layer.mask = maskLayer;
  [self.view addSubview:imageView];
}

這三種方法中第三種最好,對內(nèi)存的消耗最少啊,而且渲染快速。

效果圖:

iOS設置圓角的方法有哪些

以上是“iOS設置圓角的方法有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

分享文章:iOS設置圓角的方法有哪些
路徑分享:http://www.chinadenli.net/article20/iiehjo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化網(wǎng)站內(nèi)鏈定制開發(fā)網(wǎng)站策劃面包屑導航自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設