在做一个NavigationController push 子页面时,发现push和pop时很卡,研究了一大阵子后,发现在子页面里影响UI流畅的只有UIImageView的圆角设置;然后我就关闭了圆角,重新运行果然流畅多了。但是产品的需求必须加圆角,没办法,去stackoverflow找方案,发现方法都大同小异,只不过是绘制上做一些优化。后来查看layer的头文件,最后找到了一个牛B的属性:

  1. /* When true, the layer is rendered as a bitmap in its local coordinate
  2. * space ("rasterized"), then the bitmap is composited into the
  3. * destination (with the minificationFilter and magnificationFilter
  4. * properties of the layer applied if the bitmap needs scaling).
  5. * Rasterization occurs after the layer's filters and shadow effects
  6. * are applied, but before the opacity modulation. As an implementation
  7. * detail the rendering engine may attempt to cache and reuse the
  8. * bitmap from one frame to the next. (Whether it does or not will have
  9. * no affect on the rendered output.)
  10. *
  11. * When false the layer is composited directly into the destination
  12. * whenever possible (however, certain features of the compositing
  13. * model may force rasterization, e.g. adding filters).
  14. *
  15. * Defaults to NO. Animatable. */
  16. @property BOOL shouldRasterize;
  17. /* The scale at which the layer will be rasterized (when the
  18. * shouldRasterize property has been set to YES) relative to the
  19. * coordinate space of the layer. Defaults to one. Animatable. */
  20. @property CGFloat rasterizationScale;

当shouldRasterize设成true时,layer被渲染成一个bitmap,并缓存起来,等下次使用时不会再重新去渲染了。实现圆角本身就是在做颜色混合(blending),如果每次页面出来时都blending,消耗太大,这时shouldRasterize = yes,下次就只是简单的从渲染引擎的cache里读取那张bitmap,节约系统资源。

额外收获:如果在滚动tableView时,每次都执行圆角设置,肯定会阻塞UI,设置这个将会使滑动更加流畅。

ios开发中view.layer.shouldRasterize = YES 的使用说明的更多相关文章

  1. iOS开发中view controller设置问题

  2. IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法

    在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...

  3. ios开发中的小技巧

    在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIViewal ...

  4. iOS开发中你是否遇到这些经验问题

    前言 小伙伴们在开发中难免会遇到问题, 你是如何解决问题的?不妨也分享给大家!如果此文章其中的任何一条问题对大家有帮助,那么它的存在是有意义的! 反正不管怎样遇到问题就要去解决问题, 在解决问题的同时 ...

  5. iOS开发中遇到的一些问题及解决方案【转载】

    iOS开发中遇到的一些问题及解决方案[转载] 2015-12-29 [385][scrollView不接受点击事件,是因为事件传递失败] // //  MyScrollView.m //  Creat ...

  6. IOS开发中AVFoundation中AVAudioPlayer的使用

    IOS开发中如何调用音频播放组件 1.与音频相关的头文件等都在AVFoundation.h中,所以第一步是添加音频库文件: #import <AVFoundation/AVFoundation. ...

  7. iOS开发中静态库制作 之.a静态库制作及使用篇

    iOS开发中静态库之".a静态库"的制作及使用篇 一.库的简介 1.什么是库? 库是程序代码的集合,是共享程序代码的一种方式 2.库的类型? 根据源代码的公开情况,库可以分为2种类 ...

  8. iOS开发中设置UITextField的占位文字的颜色,和光标的颜色

    在iOS开发中,对于很多初学者而言,很有可能碰到需要修改UITextField的占位文字的颜色,以及当UITextField成为第一响应者后光标的颜色,那么下面小编就介绍一下修改占位文字和光标的颜色. ...

  9. iOS开发中打电话发短信等功能的实现

    在APP开发中,可能会涉及到打电话.发短信.发邮件等功能.比如说,通常一个产品的"关于"页面,会有开发者的联系方式,理想情况下,当用户点击该电话号码时,能够自动的帮用户拨出去,就涉 ...

随机推荐

  1. tableau-基本函数

    一.数据术语 维度——包含诸如文本和日期等类别数据的字段. 度量——包含可以聚合的数字的字段. 二.字段图标 Abc  蓝色图标->离散字段 #     绿色图标->连续字段 =Abc = ...

  2. php 中的 Output Control 函数

    先看一个简单的例子 <?php ob_start(); echo 111; ob_clean(); echo 222; ob_start()开启ob缓存,然后111放进了ob缓存, 再调用ob_ ...

  3. 剑指offer第五章

    剑指offer第五章 1.数组中出现次数超过一半的数 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字. 例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组 ...

  4. 《selenium2 python 自动化测试实战》(13)——上传文件

    看代码: # coding: utf-8 from selenium import webdriver from time import sleep driver = webdriver.Firefo ...

  5. python ctypes 和windows DLL互相调用

    图片项目

  6. php、打印

    <!DOCTYPE HTML><html><head><meta http-equiv="content-type" content=&q ...

  7. torcs代码

    /** Info returned by driver during the race */ typedef struct { tdble steer; /**< Steer command [ ...

  8. Python——str常用操作方法

    1. 索引(即下标) s = 'ABCDEFGHIJKLMN' s1 = s[0] print('s[0] = ' + s1) #s[0] = A print('s[3] = '+ s[3]) #s[ ...

  9. Unit02: 参数值注入 、 基于注解的组件扫描

    Unit02: 参数值注入 . 基于注解的组件扫描 (4)IOC (Inversion Of Controll 控制反转) 什么是IOC? 对象之间的依赖关系由容器来建立. 什么是DI? (Depen ...

  10. Oracle数据库clob字段导出为sql insert插入语句

    oracle数据库的clob字段导出为sql insert插入语句可以分三种情况:1,clob没有换行符:2,clob有换行符但不以分号结尾:3,clob有换行符并且以分号结尾. clob没有换行符使 ...