在做一个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. python笔记-8(logging模块、re模块、栈与队列)

    一.Logging模块日志 1.logging导入 Import logging 2.知道5个日志级别的等级关系 Debug->info->warning->error->cr ...

  2. python selenium 开发环境配置

    selenium是一个web测试应用框架也可以拿来做爬虫. 1.安装selenium模块 pip install -U selenium 2.安装selenium模块后需要有相应的浏览器驱动 A.使用 ...

  3. drone 学习六 发布部署&&集成私有容器仓库&&构建代码s3 保存

    备注:      需要进行drone 以及gitlab 环境的配置,可以参考相关资料   1. 参考项目 https://github.com/rongfengliang/drone-appdemo ...

  4. Quick 3.3 的代码资源加密

    http://cn.cocos2d-x.org/tutorial/show?id=1507 http://cn.cocos2d-x.org/tutorial/show?id=1447 http://b ...

  5. Oracle安装-------实例化EM 配置文件时出错问题 ( 转 )

    命令行中执行: C:\Users\Administrator>emca -repos drop   EMCA 开始于 2013-4-23 20:13:58 EM Configuration As ...

  6. Web 漏洞分析与防御之 CSRF(二)

    原文地址:Web 漏洞分析与防御之 CSRF(二) 博客地址:http://www.extlight.com 一.全称 跨站请求伪造(Cross-site Request Forgery) 二.原理 ...

  7. Python--线性代数篇

    讲解Python在线性代数中的应用,包括: 一.矩阵创建 先导入Numpy模块,在下文中均采用np代替numpy import numpy as np 矩阵创建有两种方法,一是使用np.mat函数或者 ...

  8. 国内DP厂家的相关资料信息

    这两天看了国内各个厂家的DSP开发板,总结一下,希望给同样需要的人一点经验和总结. 因为我是做通信系统,所以需要TI公司的C6000系列处理器. 目前C6000系列性能最强的是C66X系列,该系列的C ...

  9. Windows Server 2012十大实用快捷键组合

    在本文中,我们将一起体验快捷键如何在微软最新服务器操作系统中帮助用户提升工作效率. 微软推出的最新服务器操作系统比我印象中任何一款前代Windows Server产品都依赖于键盘操作——当然,这些产品 ...

  10. python学习 (三十五) logging

    1  demo import logging # log level: # DEBUG # INFO # Warning # Error # CRITICAL logging.basicConfig( ...