YYKit源码讲解(4)

接下来看base文件夹下的Quartz 文件夹内容

这个文件夹下的类不多

CALayer+YYAdd.h

YYCGUtilities


1.CALayer+YYAdd.h

好多函数和UIView 的重合,这里不做介绍了

- (CGFloat)transformRotation

- (void)setTransformRotation:(CGFloat)v

设置或者获取旋转角度

- (CGFloat)transformRotationX

- (void)setTransformRotationX:(CGFloat)v

设置或者获取x轴旋转角度

- (CGFloat)transformRotationY

- (void)setTransformRotationY:(CGFloat)v

设置或者获取y轴旋转角度

- (CGFloat)transformRotationZ

- (void)setTransformRotationZ:(CGFloat)v

设置或者获取z轴旋转角度

- (CGFloat)transformScaleX

- (void)setTransformScaleX:(CGFloat)v

- (CGFloat)transformScaleY

- (void)setTransformScaleY:(CGFloat)v

- (CGFloat)transformScaleZ

- (void)setTransformScaleZ:(CGFloat)v

xyz轴的缩放

- (CGFloat)transformScale

- (void)setTransformScale:(CGFloat)v

平面缩放

- (CGFloat)transformTranslationX

- (void)setTransformTranslationX:(CGFloat)v

- (CGFloat)transformTranslationY

- (void)setTransformTranslationY:(CGFloat)v

- (CGFloat)transformTranslationZ

- (void)setTransformTranslationZ:(CGFloat)v 

平移

- (CGFloat)transformDepth {

return self.transform.m34;

}


- (void)setTransformDepth:(CGFloat)v {

CATransform3D d = self.transform;

d.m34 = v;

self.transform = d;

}

设置深度

这篇文章讲解什么是m34的。 

- (UIViewContentMode)contentMode

- (void)setContentMode:(UIViewContentMode)contentMode

NSString *YYUIViewContentModeToCAGravity(UIViewContentMode contentMode) {

switch (contentMode) {

case UIViewContentModeScaleToFill: return kCAGravityResize;

case UIViewContentModeScaleAspectFit: return kCAGravityResizeAspect;

case UIViewContentModeScaleAspectFill: return kCAGravityResizeAspectFill;

case UIViewContentModeRedraw: return kCAGravityResize;

case UIViewContentModeCenter: return kCAGravityCenter;

case UIViewContentModeTop: return kCAGravityTop;

case UIViewContentModeBottom: return kCAGravityBottom;

case UIViewContentModeLeft: return kCAGravityLeft;

case UIViewContentModeRight: return kCAGravityRight;

case UIViewContentModeTopLeft: return kCAGravityTopLeft;

case UIViewContentModeTopRight: return kCAGravityTopRight;

case UIViewContentModeBottomLeft: return kCAGravityBottomLeft;

case UIViewContentModeBottomRight: return kCAGravityBottomRight;

default: return kCAGravityResize;

}

}

UIViewContentMode  和 kCAGravity 之间做的转换桥接

- (void)addFadeAnimationWithDuration:(NSTimeInterval)duration curve:(UIViewAnimationCurve)curve

- (void)removePreviousFadeAnimation

增加几种过度动画

YYCGUtilities.h

CGContextRef YYCGContextCreateARGBBitmapContext(CGSize size, BOOL opaque, CGFloat scale)

获取bitmap上下文context 

这里opaque 要是yes 就没有透明度了

CGContextRef YYCGContextCreateGrayBitmapContext(CGSize size, CGFloat scale)

创建bitmap上下文,只有灰色的 。

CGFloat YYScreenScale() 

获取scale

CGSize YYScreenSize()

获取屏幕大小

还有一些矩阵计算的东东不看了,有时间回来从新看的时候在学习吧,让剩下部分烂尾吧。

你可能感兴趣的:(YYKit源码讲解(4))