封装View注意细节
2018-07-29 本文已影响14人
CoderHong
细节一 设置内部子控件的Frame
-
重写
layoutSubViews
方法设置内部子控件的Frame-
layoutSubViews.png
-
细节二 添加内部子控件写在initWithFrame
中
-
因为外界创建view的如果使用init方法,
inint
方法内部会首先调用initWithFrame
方法。-
initWithFrame.png
-
相反,调用initWithFrame方法内部不会调用init方法。