詳談iPhoneX截圖如何帶
直接用iPhoneX截圖后是沒(méi)有圓角和劉海的,就像下面這樣。
其實(shí)加圓角和劉海也很簡(jiǎn)單
第一步:截屏
第二步:打開我這個(gè)軟件,并選取圖片庫(kù)中的那張圖
第三步:添加圓角,劉海
第四步:將做好的圖片保存到相冊(cè)
還需要下邊這張劉海的圖片
可以上代碼了(目前原圖是固定的,沒(méi)有從圖片庫(kù)選?。?/p>
// // ViewController.m // iPhoneXPhotoEdit // // Created by yfc on 2017/12/23. // Copyright © 2017年 yfc. All rights reserved. // #import "ViewController.h" #import <AssetsLibrary/AssetsLibrary.h> #import <Photos/Photos.h> @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *btn = [[UIButton alloc]init]; btn.frame = CGRectMake(10, 44, 350, 758); btn.frame = CGRectMake(0, 0, 375, 812); [btn setBackgroundImage:[UIImage imageNamed:@"IMG_3655.PNG"] forState:UIControlStateNormal]; //添加圓角 btn.layer.cornerRadius = 35 ; btn.layer.borderColor = [UIColor blackColor].CGColor; btn.layer.borderWidth = 2; [self.view addSubview:btn]; btn.backgroundColor = [UIColor whiteColor]; btn.clipsToBounds = YES; //添加劉海 UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"liuhai.png"]]; imageView.frame = CGRectMake(70, 0, 222, 28); [btn addSubview:imageView]; self.view.backgroundColor = [UIColor clearColor]; //截圖保存到相冊(cè) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self saveBtnAction:nil]; }); } -(void)saveBtnAction:(UIButton *)sender{ [self requestAuthorizationStatus]; } //查看權(quán)限 - (void)requestAuthorizationStatus { [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){ dispatch_async(dispatch_get_main_queue(), ^{ switch (status) { case PHAuthorizationStatusAuthorized: { [self cutScreen]; break; } default://Denied { break; } } }); }]; } //截屏 -(void)cutScreen{ UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0.0); //2.獲取當(dāng)前圖形上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); //3.獲取需要截取的view的layer [self.view.layer renderInContext:ctx]; //4.從當(dāng)前上下文獲取圖片 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); //5.關(guān)閉圖形上下文 UIGraphicsEndImageContext(); //6.把圖片保存到相冊(cè) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL); } //保存成功后回調(diào) -(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ NSString *msg = nil; if (error) { msg = @"圖片保存失敗"; }else{ msg = @"圖片保存成功"; } UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil]; [alertView show]; } @end
效果圖是
以上這篇詳談iPhoneX截圖如何帶"劉海"和圓角就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
iOS應(yīng)用中UISearchDisplayController搜索效果的用法
這篇文章主要介紹了iOS應(yīng)用中UISearchDisplayController搜索效果的用法,包括點(diǎn)擊搜索出現(xiàn)黑條問(wèn)題的解決方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-02-02IOS實(shí)現(xiàn)百度地圖自定義大頭針和氣泡樣式
這篇文章主要介紹了 IOS百度地圖自定義大頭針和氣泡的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2016-12-12iOS音樂(lè)播放器實(shí)現(xiàn)代碼完整版
這篇文章主要為大家詳細(xì)介紹了iOS音樂(lè)播放器實(shí)現(xiàn)代碼完整版,包括音頻列表、播放器、后臺(tái)播放、鎖屏播放,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05IOS 開發(fā)之網(wǎng)絡(luò)圖片輪播圖的實(shí)現(xiàn)
這篇文章主要介紹了IOS 開發(fā)之網(wǎng)絡(luò)圖片輪播圖的實(shí)現(xiàn)的相關(guān)資料,希望通過(guò)此文大家能夠掌握輪播圖的實(shí)現(xiàn),需要的朋友可以參考下2017-09-09iOS從App跳轉(zhuǎn)至系統(tǒng)設(shè)置菜單各功能項(xiàng)的編寫方法講解
這篇文章主要介紹了iOS從App跳轉(zhuǎn)至系統(tǒng)設(shè)置菜單各功能項(xiàng)的編寫方法講解,示例代碼為傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-04-04MAC中顯示隱藏文件和不顯示隱藏文件的方法(超簡(jiǎn)單)
下面小編就為大家分享一篇MAC中顯示隱藏文件和不顯示隱藏文件的方法(超簡(jiǎn)單),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01iOS應(yīng)用中UITableView左滑自定義選項(xiàng)及批量刪除的實(shí)現(xiàn)
這篇文章主要介紹了iOS應(yīng)用中UITableView左滑自定義選項(xiàng)及批量刪除的實(shí)現(xiàn),UITableView列表中即通訊錄左滑呼出選項(xiàng)的那種效果在刪除時(shí)能夠?qū)崿F(xiàn)多行刪除將更加方便,需要的朋友可以參考下2016-03-03IOS 開發(fā)之應(yīng)用喚起實(shí)現(xiàn)原理詳解
這篇文章主要介紹了IOS 開發(fā)之應(yīng)用喚起實(shí)現(xiàn)原理詳解的相關(guān)資料,需要的朋友可以參考下2016-12-12