工具类YJUtils
发布时间:2020-12-14 01:33:29 所属栏目:百科 来源:网络整理
导读:在Swift开发工程中,我们会封装一些常用的工具类,这里我封装了YJUtils。 // // YJUtils.swift // Utils // // CSDN:http://blog.csdn.net/y550918116j // GitHub:https://github.com/937447974/Blog // // Created by yangjun on 15/12/14. // Copyright ?
在Swift开发工程中,我们会封装一些常用的工具类,这里我封装了YJUtils。 //
// YJUtils.swift
// Utils
//
// CSDN:http://blog.csdn.net/y550918116j
// GitHub:https://github.com/937447974/Blog
//
// Created by yangjun on 15/12/14.
// Copyright ? 2015年 阳君. All rights reserved.
//
import UIKit
/// user interface
public struct YJUtilUserInterfaceIdiom {
/// The user interface should be designed for iPhone and iPod touch.
static let isPhone = UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone
/// The user interface should be designed for iPad.
static let isPad = UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad
/// The user interface should be designed for Apple TV.
static let isAppleTv = UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.TV
}
/// 屏幕尺寸
public struct YJUtilScreenSize {
/// 屏幕宽
static let screenWidth = UIScreen.mainScreen().bounds.size.width
/// 屏幕高
static let screenHeight = UIScreen.mainScreen().bounds.size.height
/// 屏幕最大长度
static let screenMaxLength = max(YJUtilScreenSize.screenWidth,YJUtilScreenSize.screenHeight)
/// 屏幕最小长度
static let screenMinLength = min(YJUtilScreenSize.screenMaxLength,YJUtilScreenSize.screenHeight)
}
/// 机型
public struct YJUtilDeviceType {
/// IPhone4
static let isIPhone4 = YJUtilUserInterfaceIdiom.isPhone && YJUtilScreenSize.screenMaxLength == 480.0
/// IPhone5
static let isIPhone5 = YJUtilUserInterfaceIdiom.isPhone && YJUtilScreenSize.screenMaxLength == 568.0
/// IPhone6
static let isIPhone6 = YJUtilUserInterfaceIdiom.isPhone && YJUtilScreenSize.screenMaxLength == 667.0
/// IPhone6P
static let isIPhone6P = YJUtilUserInterfaceIdiom.isPhone && YJUtilScreenSize.screenMaxLength == 736.0
}
其他源代码Swift 文档修改记录
版权所有CSDN:http://blog.csdn.net/y550918116j GitHub:https://github.com/937447974/Blog (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |