xcode7启动页的尺寸设置,xcode7启动尺寸

iPhone Portrait iOS 8,9-Retina HD 5.5 (1242×2208) @3x 
iPhone Portrait iOS 8,9-Retina HD 4.7 (750×1334) @2x
iPhone Portrait iOS 7,9-2x (640×960) @2x 
iPhone Portrait iOS 7,9-Retina 4 (640×1136) @2x
iPhone Portrait iOS 5,6-1x (320×480) @1x 
iPhone Portrait iOS 5,6-2x (640×960) @2x 
iPhone Portrait iOS 5,6-Retina4 (640×1136) @2x

 

图片 1

iPhone
Portrait iOS 8,9-Retina HD 5.5 (12422208) @3x iPhone Portrait iOS
8,9-Retina HD 4.7 (7501334) @2x iPhone Port…

启动页

landscape 代表横屏
portrait 代表竖屏

/

常用的4个
【iPhone portrait iOS 8,9】
Retina HD 5.5 1242×2208
Retina HD 4.7 750×1334
【iPhone Portrait iOS 7-9】
2x 640×960
Retina 4 640×1136

/

包含所有的启动页大小
【iPhone portrait iOS 8,9】
Retina HD 5.5 1242×2208
Retina HD 4.7 750×1334
【iPhone Landscape iOS 8,9】
Retina HD 5.5 2208×1242
【iPhone Portrait iOS 7-9】
2x 640×960
Retina 4 640×1136
【iPad Portrait iOS 7-9】
1x 768×1024
2x 1536×2048
【iPad Landscape iOS 7-9】
1x 1024×768
2x 2048×1536

目录1、ATS配置2、状态栏全局变亮白3、懒加载4、内存泄漏5、常用的第三方库6、反射机制7、运行时8、MD5加密9、聊天界面10、多线程GCD11、
启动图尺寸大小12 、权限

图标

授之于鱼不如授之于渔,我这用Xcode 8.0 看到的

图片 2

033D5918-1623-4989-B1E9-68982F55AD15.png

如图:
iPhone Notification iOS 7-10 20pt
2x 需要的尺寸是 20ptx2 = 40 40×40

名称 尺寸
iPhone Notification iOS 7-10 20pt
iPhone Spoting-iOS 5,6 settings -iOS 5-10 29pt
iPhone Spoting iOS 7-10 40pt
iPhone APP iOS 7-10 60pt
iPad Notifications iOS 7-10 20pt
iPad settings -iOS 5-10 29pt
iPad Spoting iOS 7-10 40pt
iPad APP iOS 7-10 76pt
iPad Pro APP iOS 9-10 83.5pt

图片 3

2F9E22A4-E6B0-43D0-BEFE-8162F3FE37EA.png

iPhone Portrait iOS 8-Retina HD 5.5 (1242×2208) @3x
iPhone Portrait iOS 8-Retina HD 4.7 (750×1334) @2x

iPhone Portrait iOS 7,8-2x (640×960) @2x
iPhone Portrait iOS 7,8-Retina 4 (640×1136) @2x

iPhone Portrait iOS 5,6-1x (320×480) @1x
iPhone Portrait iOS 5,6-2x (640×960) @2x
iPhone Portrait iOS 5,6-Retina4 (640×1136) @2x

iPad
768 x 1024 pixels
1536 x 2048 pixels (@2x)
1024 x 768 pixels
2048 x 1536 pixels (@2x)

1、ATS配置

App 网络http请求已被禁止,需要在Info.plist文件配置。

 <key>NSAppTransportSecurity</key><dict> <key>NSAllowsArbitraryLoads</key> <true/></dict>

2、状态栏全局变亮白

 UIApplication.shared.statusBarStyle = .lightContent

还需要在Info.plist文件配置:

<key>UIViewControllerBasedStatusBarAppearance</key> <false/>

3、懒加载

lazy var mainScrollView:UIScrollView = {()-> UIScrollView in let scrollView = UIScrollView() return scrollView }()

4、内存泄漏

解决闭包循环引用[weak self]

//ESPullToRefresh上拉加载 var footer: ESRefreshProtocol & ESRefreshAnimatorProtocol footer = ESRefreshFooterAnimator.init(frame: CGRect.zero) homeTableView.es.addInfiniteScrolling(animator: footer) { [weak self] in self?.pageArray[tag]+=1 self?.initData(tag:tag+1,page:(self?.pageArray[tag]) ?? 1) }

Timer释放内存

var timer:Timer? override func viewDidLoad() { super.viewDidLoad() if #available(iOS 10.0, *) { timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: {  in print }) } else { timer=Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector, userInfo: nil, repeats: true) } timer?.fire() //启动定时器 //timer?.fireDate=Date.distantFuture //暂停定时器}@objc func write(){ print } deinit{ timer?.invalidate() timer=nil print }

CADisplayLink释放内存

let displayLink = CADisplayLink.init(target: self, selector: #selectordisplayLink?.frameInterval = 1displayLink?.add(to: .current, forMode: .commonModes)//displayLink?.isPaused=false//暂停或开始定时器//销毁定时器必须先执行(deinit在这之后执行)displayLink?.invalidate()//然后再执行displayLink=nil

WKWebView释放内存

//遵守WKScriptMessageHandler协议 webView = WKWebView.init(frame: self.view.bounds) let request=URLRequest.init(url: URL.init(string: "http://www.jianshu.com/u/665ff1bc9038")!) webView?.load webView?.configuration.userContentController.add(self, name: "Delete") self.view.addSubview//实现代理方法func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { if "Delete" == message.name { } }//销毁WKWebView对象必须先执行(deinit在这之后执行)webView?.configuration.userContentController.removeScriptMessageHandler(forName: "Delete")//然后再执行webView=nil

NotificationCenter通知

//发送通知let center = NotificationCenter.defaultcenter.post(name: NSNotification.Name(rawValue: "Notification"), object: "传单个值")center.post(name: NSNotification.Name(rawValue: "Notification_More"), object: nil, userInfo: ["name":"星星编程","experience":"3年"])//接收通知 var center = NotificationCenter.default var observer:NSObjectProtocol? override func viewDidLoad() { super.viewDidLoad() center.addObserver(self, selector: #selector, name: NSNotification.Name(rawValue: "Notification"), object: nil) observer = center.addObserver(forName: NSNotification.Name(rawValue: "Notification_More"), object: nil, queue: OperationQueue.main) { (notification) in print(notification.userInfo ?? "") } } @objc func receive(notification:Notification){ print("接收到消息:" + "\(notification.object ?? "")") } deinit { //center.removeObserver//销毁所以通知中心的监听,不能销毁NSObjectProtocol的监听 center.removeObserver(self, name: NSNotification.Name(rawValue: "Notification"), object: nil) // center.removeObserver(observer ?? self)//销毁NSObjectProtocol的监听 center.removeObserver(observer ?? self, name: NSNotification.Name(rawValue: "Notification_More"), object: nil) print }

5、常用的第三方库

网络请求和生成Model的框架:AlamofireObjectMapper首页图片轮播框架:GLLoopView图片加载框架:Kingfisher上拉刷新下拉加载框架:ESPullToRefresh

6、反射机制

Mirror

class Book : NSObject { var name:String? //书名 var author:String? //作者 var pages:Int? //页数} let book = Book() book.name = "简书" book.author = "星星编程" book.pages = 100 //是否是Book类的一个实例或实例的任何类继承自Book类 if book.isKind(of: Book.classForCoder{ print("book是Book的一个实例") } //是否是Book类的一个实例 if book.isMember(of: Book.classForCoder { print("book是Book的一个实例") } //判断self是否实现了aa方法 if self.responds(to: #selector{ print } //发送一个消息到指定消息的接收器,并返回结果 self.perform(#selector //将对象进行反射 let mirror = Mirror(reflecting: book) print("对象类型:\(mirror.subjectType)") print("对象子元素个数:\(mirror.children.count)") print("--- 对象子元素的属性名和属性值分别如下 ---") for case let (key?, value) in mirror.children { print("属性:\ 值:\ }

NSClassFromString

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { window = UIWindow() window?.backgroundColor = UIColor.white //设置跟控制器要添加命名空间(默认是项目名称,最好不要有特殊符号) let clsName = "StarsSwift.ViewController" let cls = NSClassFromString as? UIViewController.Type //使用类来创建视图控制器 let vc = cls?.init() window?.rootViewController = vc window?.makeKeyAndVisible() return true }

7、运行时

//通过KVC给对象赋值 let book = Book(dict: ["name" : "简书" , "author" : "星星编程" ,"introduction" : "假如编程欺骗了你,你依旧义无反顾的热爱编程,这才叫真爱。" ]) print("书名:\(book.name ?? "") 作者:\(book.name ?? "") 简介:\(book.introduction ?? "")") //打印通过运行时获取类的属性 print(Book.propertyList//书类class Book : NSObject{ @objc var name:String? //书名 @objc var author:String? //作者 @objc var introduction:String? //简介 init(dict:[String:Any]) { super.init() self.setValuesForKeys } override func setValue(_ value: Any?, forUndefinedKey key: String) { } class func propertyList()->[String]{ var count:UInt32=0 //获取类的属性列表,返回属性列表数组 let list=class_copyPropertyList(self, &count) var propertyList=[String]() for i in 0..<Int{ guard let pty = list?[i] else{ continue } let cName=property_getName guard let name = String.init(utf8String: cName) else{ continue } propertyList.append } free return propertyList }}

8、MD5加密

//// String+MD5.swift// StarsSwift//// Created by 李永飞 on 2017/10/26.// Copyright © 2017年 李永飞. All rights reserved.//import Foundationextension String { var md5: String { if let data = self.data(using: .utf8, allowLossyConversion: true) { let message = data.withUnsafeBytes { bytes -> [UInt8] in return Array(UnsafeBufferPointer(start: bytes, count: data.count)) } let MD5Calculator = MD5 let MD5Data = MD5Calculator.calculate() var MD5String = String() for c in MD5Data { MD5String += String(format: "%02x", c) } return MD5String } else { return self } }}

9、聊天界面

图片 4消息列表.png图片 5好友列表.png图片 6聊天界面.png

10、多线程GCD

加载网络数据及时更新UI

 DispatchQueue.global().async { //加载网络数据 DispatchQueue.main.async(execute: { //更新UI }) }

延迟加载

 DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: { //更新UI })

DispatchGroup

 let group = DispatchGroup() let queueTask1 = DispatchQueue(label: "book") queueTask1.async(group: group) { print } let queueTask2 = DispatchQueue(label: "video") queueTask2.async(group: group) { print } group.notify(queue: DispatchQueue.main) { print }

DispatchWorkItem

let queueTask = DispatchQueue(label: "queueTask", attributes: .concurrent)let workItem1 = DispatchWorkItem { print("WorkItem1") }let workItem2 = DispatchWorkItem { print("WorkItem2") }queueTask.async(execute: workItem1)queueTask.async(execute: workItem2)

DispatchGroup和DispatchWorkItem一起使用

 let group = DispatchGroup() let queueTask1 = DispatchQueue(label: "book") queueTask1.async(group: group) { print } let queueTask2 = DispatchQueue(label: "video") queueTask2.async(group: group) { print }let queueTask = DispatchQueue(label: "queueTask", attributes: .concurrent)let workItem1 = DispatchWorkItem { print("WorkItem1") }let workItem2 = DispatchWorkItem { print("WorkItem2") } queueTask.async(group: group, execute: workItem1) queueTask.async(group: group, execute: workItem2) group.notify(queue: DispatchQueue.main) { print }

11、 启动图尺寸大小

iPhone Portrait iOS 11+ iPhone X (1125×2436) @3x

iPhone Portrait iOS 8,9-Retina HD 5.5 (1242×2208) @3xiPhone Portrait
iOS 8,9-Retina HD 4.7 @2x

iPhone Portrait iOS 7,8,9-2x @2xiPhone Portrait iOS 7,8,9-Retina 4 @2x

iPhone Portrait iOS 5,6-1x @1xiPhone Portrait iOS 5,6-2x @2xiPhone
Portrait iOS 5,6-Retina4 @2x

12、 权限

通讯录 NSContactsUsageDescription麦克风 NSMicrophoneUsageDescription相册
NSPhotoLibraryUsageDescription相机
NSCameraUsageDescription添加图片到相册
NSPhotoLibraryAddUsageDescription持续获取地理位置
NSLocationAlwaysUsageDescription使用时获取地理位置
NSLocationWhenInUseUsageDescription蓝牙
NSBluetoothPeripheralUsageDescription语音转文字
NSSpeechRecognitionUsageDescription日历 NSCalendarsUsageDescription

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章