探索iOS开发:Interface Builder与Leveler应用实践
1. 使用Interface Builder优化SYShapeView
在开发过程中,我们已经复制了使用 -initWithShape: 方法创建的新 SYShapeView 对象的大小和属性,但形状属性稍后再处理。具体操作步骤如下:
- 修改SYShapeView.h文件 :
- 移除 -initWithShape: 方法原型。
- 替换为新属性:
@property (nonatomic) ShapeSelector shape;
这样形状属性就可设置了,后续由于不能再使用 -initWithShape: 创建对象(Interface Builder将使用 -initWithCoder: 创建),这个属性会很有用。
- 修改SYShapeView.m文件 :
- 丢弃 kInitialDimension 和 kInitialAlternateHeight 的定义。
- 从私有 @interface SYShapeView () 指令中移除形状实例变量。
- 删除整个 -initWithShape: 方法。
-
超级会员免费看
订阅专栏 解锁全文
923

被折叠的 条评论
为什么被折叠?



