zoukankan      html  css  js  c++  java
  • 对于UITableView和UIImageView的DrawRect重写之后的影响

    一、继承 UITableView和UIImageView , 重写 DrawRect 方法,然后里面留空

      ImageView

    @implementation DrawImageView
    
    - (void)drawRect:(CGRect)rect {
        // Drawing code
    }
    
    
    @end
    

      Table

    @implementation DrawTestTable
    
    - (void)drawRect:(CGRect)rect
    {
        
    }
    
    @end
    

      结果

    二、分析

      对于UITableView来说,最终显示的内容是 cell 和 header, UITableView只是作为一个容器,系统不在这个容器上面绘制任何内容

      对于UIImageView来说,真正显示的内容在CALAyer的ID上,这里和DrawRect中的绘制并不冲突

      与UILabel不太相同的是,UILabel中的文字是真正“画”上去的, UITableView 和 UIImageView 是通过设置另外的属性,由render server叠加上去的

      因此,对于UIView的属性,背景色之类的属性,这些和DrawRect也不冲突,两个可以同时生效。

      通过比较不同的UIKit组件,可以大概知道UIKit绘制的原理。

    Demo下载地址:

    https://files.cnblogs.com/files/doudouyoutang/DrawTest.zip

      

  • 相关阅读:
    通过ip找mac
    python开发总结
    iptables 通用语句
    运行pyqt4生成py文件增加代码
    re正则match、search、findall、finditer函数方法使用
    python list 字符串排序
    读取yaml文件小方法
    递归解析字典小方法
    assert 断言
    格式化字符串——初级% 和format
  • 原文地址:https://www.cnblogs.com/doudouyoutang/p/11027962.html
Copyright © 2011-2022 走看看