OC基础学习11:协议

1 正式协议 声明协议 1 2 3 @protocol NSCoding - (id) copyWithZone: (NSZone *) zone; @end 继承父协议: 1 2 @protocol MySuperDuberProtocol <MyParentProtocol> @end 采用协议 1 2 3 4 5 6 @interface Car :NSObject <NSCopying, NSCoding> { // instance variables } // methods @end // Car 实现协议

OC基础学习9:属性

1 使用属性 接口代码简化 没有使用属性: 1 2 3 4 5 6 7 8 9 10 11 12 13 #import "Tire.h" @interface AllWeatherRadial : Tire { // 轮胎在潮湿和积雪的道路上的性能 float rainHandling; float snowHandling; } - (void) setRainHandling:(float)rainHandling; - (float) rainHandling; - (void) setSnowHandling:(float)snowHandling; - (float)

iOS动画(二):核心动画中的基础移动(Swift)

简单的移动 新建一个CALayer。 1 2 3 4 5 6 7 8 9 10 lazy var redLayer: CALayer = { return self.createLayer() }() func createLayer() -> CALayer { let redLayer = CALayer() redLayer.position = CGPoint(x: 200, y: 200) redLayer.bounds = CGRect(x: 0, y: 0, width: 100, height: 100) redLayer.backgroundColor = UIColor.red.cgColor return redLayer } 把新建