IOS开发中常用的代码块收集整理
9页1、IOSIOS 开发中常用的代码块收集整理开发中常用的代码块收集整理收集常用的代码块是加快开发的有效途径,收集的操作步骤这里不在赘述,仅仅贡献上一些常用的功能性代码1、与高度和宽度有关的? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34/*获取导航栏高度*/public func getNavigationBarHeight() - CGFloat let navRect:CGRect! = self.navigationController?.navigationBar.framereturn navRect.size.height/*获取标签栏高度*/public func getTabBarHeight() - CGFloat let tabBarRect:CGRect! = self.tabBarController?.tabBar.framereturn tabBarRect.size.height/*获取状态栏高度*/public func
2、 getStatusBarHeight() - CGFloat let rectStatus:CGRect = UIApplication.shared.statusBarFramereturn rectStatus.size.height/*根据提供的字体大小,宽度获取字文字的高度*/func getTextHeigh(textStr:String,font:UIFont,width:CGFloat) - CGFloat let normalText: NSString = textStr as NSStringlet size = CGSize(width: width, height: 10000)let dic:NSDictionary = NSDictionary(object: font, forKey: NSAttributedStringKey.font as NSCopying)let stringSize = normalText.boundingRect(with: size, options: .usesLineFragmentOrigin, attribute
3、s: dic as? NSAttributedStringKey : Any, context:nil).sizereturn stringSize.height/*提供文字大小,控件高度,获取到文字的宽度*/func getTexWidth(textStr:String,font:UIFont,height:CGFloat) - CGFloat let normalText: NSString = textStr as NSString35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51let size = CGSize(width: 10000, height: height)let dic:NSDictionary = NSDictionary(object: font, forKey: NSAttributedStringKey.font as NSCopying)let stringSize = normalText.boundingRect(with: size, options: .usesLineFragmentOrigi
4、n, attributes: dic as? NSAttributedStringKey : Any, context:nil).sizereturn stringSize.width + 40UIScreen.main.bounds.size.width / 屏幕宽度UIScreen.main.bounds.size.height / 屏幕高度/*UIFont 的适配(创建 UIFont 的扩展)*/+ (void)load Method newMethod = class_getClassMethod(self class, selector(adjustFont:);Method method = class_getClassMethod(self class, selector(systemFontOfSize:);method_exchangeImplementations(newMethod, method); + (UIFont *)adjustFont:(CGFloat)fontSize UIFont *newFont = nil;/BaseWidth 为设计图的尺寸n
《IOS开发中常用的代码块收集整理》由会员m****分享,可在线阅读,更多相关《IOS开发中常用的代码块收集整理》请在金锄头文库上搜索。
DB2发生死锁情况时应该怎么处理
Python 为何能成最强编程语言
面试前必须要知道的Redis面试
MySQL下自动删除指定时间以前的记录的操作方法
深入理解FastCGI协议以及在PHP中的实现
MySQL数据库性能优化之硬件瓶颈分析
NoSQL数据库大全收集整理
2018 – 2019 年前端 JavaScript 面试题
PHP文件包含漏洞的形式总结
5种使用Python代码轻松实现数据可视化的方法
改进JavaScript和Bust的互操作性:深入认识wasm-bindgen组件
C#图片缩放平移从功能分析到编码实现
详解网络蜘蛛的安全隐患及预防方法
利用NAP解除安全隐患自动隐藏你的IP地址
解决分布式数据库和离线网络中原子性问题的新方法
bbed恢复数据遇到延迟块清除的问题
Oracle Data Redaction数据加密
linux下du和df结果不一致的原因及处理
基于QMP实现对qemu虚拟机进行交互
解读Java并发队列BlockingQueue
2020-11-09 157页
2019-07-01 17页
2018-12-15 11页
2018-12-15 8页
2018-08-28 10页
2018-08-27 7页
2018-08-19 13页
2018-08-19 2页
2018-07-31 15页