提交
This commit is contained in:
36
TUIKit/TUICore/UIView+TUIUtil.m
Normal file
36
TUIKit/TUICore/UIView+TUIUtil.m
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// UIView+TUIUtil.m
|
||||
// TUICore
|
||||
//
|
||||
// Created by gg on 2021/10/9.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIView+TUIUtil.h"
|
||||
|
||||
@implementation UIView (TUIUtil)
|
||||
- (void)roundedRect:(UIRectCorner)corner withCornerRatio:(CGFloat)cornerRatio {
|
||||
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(cornerRatio, cornerRatio)];
|
||||
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
|
||||
maskLayer.frame = self.bounds;
|
||||
maskLayer.path = maskPath.CGPath;
|
||||
self.layer.mask = maskLayer;
|
||||
}
|
||||
|
||||
+ (void)showOscillatoryAnimationWithLayer:(CALayer *)layer type:(TUIOscillatoryAnimationType)type{
|
||||
NSNumber *animationScale1 = type == TUIOscillatoryAnimationToBigger ? @(1.15) : @(0.5);
|
||||
NSNumber *animationScale2 = type == TUIOscillatoryAnimationToBigger ? @(0.92) : @(1.15);
|
||||
|
||||
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
|
||||
[layer setValue:animationScale1 forKeyPath:@"transform.scale"];
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
|
||||
[layer setValue:animationScale2 forKeyPath:@"transform.scale"];
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
|
||||
[layer setValue:@(1.0) forKeyPath:@"transform.scale"];
|
||||
} completion:nil];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user