123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //
- // CALayer+Extension.h
- // iOSFastWorkStateClientOC
- //
- // Created by 翟玉磊 on 2018/11/26.
- // Copyright © 2018 翟玉磊. All rights reserved.
- //
- #import <QuartzCore/QuartzCore.h>
- typedef NS_ENUM(NSInteger, OscillatoryAnimationType) {
- OscillatoryAnimationBeBigger,
- OscillatoryAnimationBeSmaller,
- };
- @interface CALayer (Extension)<CAAnimationDelegate>
- @property (nonatomic) CGFloat left; ///< Shortcut for frame.origin.x.
- @property (nonatomic) CGFloat top; ///< Shortcut for frame.origin.y
- @property (nonatomic) CGFloat right; ///< Shortcut for frame.origin.x + frame.size.width
- @property (nonatomic) CGFloat bottom; ///< Shortcut for frame.origin.y + frame.size.height
- @property (nonatomic) CGFloat width; ///< Shortcut for frame.size.width.
- @property (nonatomic) CGFloat height; ///< Shortcut for frame.size.height.
- @property (nonatomic) CGPoint center; ///< Shortcut for center.
- @property (nonatomic) CGFloat centerX; ///< Shortcut for center.x
- @property (nonatomic) CGFloat centerY; ///< Shortcut for center.y
- @property (nonatomic) CGPoint origin; ///< Shortcut for frame.origin.
- @property (nonatomic, getter=frameSize, setter=setFrameSize:) CGSize size; ///< Shortcut for frame.size.
- @property (nonatomic) CGFloat transformRotation; ///< key path "tranform.rotation"
- @property (nonatomic) CGFloat transformRotationX; ///< key path "tranform.rotation.x"
- @property (nonatomic) CGFloat transformRotationY; ///< key path "tranform.rotation.y"
- @property (nonatomic) CGFloat transformRotationZ; ///< key path "tranform.rotation.z"
- @property (nonatomic) CGFloat transformScale; ///< key path "tranform.scale"
- @property (nonatomic) CGFloat transformScaleX; ///< key path "tranform.scale.x"
- @property (nonatomic) CGFloat transformScaleY; ///< key path "tranform.scale.y"
- @property (nonatomic) CGFloat transformScaleZ; ///< key path "tranform.scale.z"
- @property (nonatomic) CGFloat transformTranslationX; ///< key path "tranform.translation.x"
- @property (nonatomic) CGFloat transformTranslationY; ///< key path "tranform.translation.y"
- @property (nonatomic) CGFloat transformTranslationZ; ///< key path "tranform.translation.z"
- /**
- Take snapshot without transform, image's size equals to bounds.
- 截短图
- */
- - (nullable UIImage *)snapshotImage;
- /**
- Take snapshot without transform, PDF's page size equals to bounds.
- */
- - (nullable NSData *)snapshotPDF;
- /**
- Shortcut to set the layer's shadow
- 设置阴影
- @param color Shadow Color
- @param offset Shadow offset
- @param radius Shadow radius
- */
- - (void)setLayerShadow:(UIColor *_Nullable)color offset:(CGSize)offset radius:(CGFloat)radius;
- /**
- Remove all sublayers.
- 移除所有子sublayers
- */
- - (void)removeAllSublayers;
- /**
- Shortcut for transform.m34, -1/1000 is a good value.
- It should be set before other transform shortcut.
- */
- @property (nonatomic) CGFloat transformDepth;
- /**
- Add a fade animation to layer's contents when the contents is changed.
- 添加阴影动画
- @param duration Animation duration
- @param curve Animation curve.
- */
- - (void)addFadeAnimationWithDuration:(NSTimeInterval)duration curve:(UIViewAnimationCurve)curve;
- /**
- Cancel fade animation which is added with "-addFadeAnimationWithDuration:curve:".
- */
- - (void)removePreviousFadeAnimation;
- /**
- Add a spring animation to layer's contents when the contents is changed.
- 添加弹簧动画
- @param keyPath Animation keyPath
- @param duration Animation duration
- @param curve Animation curve.
- */
- - (void)addSpringAnimationWithKeyPath:(NSString *_Nullable)keyPath toPoint:(CGPoint)point duration:(NSTimeInterval)duration curve:(UIViewAnimationCurve)curve;
- // 设置border
- - (void)setBorderColor:(UIColor *_Nullable)borderColor borderWidth:(CGFloat)borderWidth cornerRadius:(CGFloat)cornerRadius;
- /**
- Add mask with roundedrect
- 添加弹簧动画
- @param rect RoundedRect
- @param corners RoundingCorners
- @param cornerRadii cornerRadii
- */
- - (void)addMaskWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;
- - (void)showScaleAnimationWithRepeatCount:(float)repeatCount;
- - (void)showOscillatoryAnimationWithType:(OscillatoryAnimationType)type;
- @end
|