cdts/xdts-ios 3/TreeHole/Code/zcqVender/ZcqVender.m

115 lines
3.8 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// ZcqVender.m
// TreeHole
//
// Created by on 2022/10/7.
//
#import "ZcqVender.h"
@implementation ZcqVender
+ (UIViewController *)theTopviewControler{
//
UIViewController *rootVC = [[UIApplication sharedApplication].delegate window].rootViewController;
UIViewController *parent = rootVC;
// presentViewController
while ((parent = rootVC.presentedViewController) != nil ) {
rootVC = parent;
}
while ([rootVC isKindOfClass:[UINavigationController class]]) {
rootVC = [(UINavigationController *)rootVC topViewController];
}
return rootVC;
}
//viewcontroller
+ (UIViewController *)getCurrentVC
{
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *currentVC = [self getCurrentVCFrom:rootViewController];
return currentVC;
}
+ (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC
{
UIViewController *currentVC;
if ([rootVC presentedViewController]) {
// presented
rootVC = [rootVC presentedViewController];
}
if ([rootVC isKindOfClass:[UITabBarController class]]) {
// UITabBarController
currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]];
} else if ([rootVC isKindOfClass:[UINavigationController class]]){
// UINavigationController
currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]];
} else {
//
currentVC = rootVC;
}
return currentVC;
}
//.
+(void)animationAlert:(UIView *)view{
CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
popAnimation.duration = 0.4;
popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DIdentity]];
popAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[view.layer addAnimation:popAnimation forKey:nil];
}
+ (NSString*)getOvertime:(NSString*)mStr{
NSTimeInterval interval =[mStr doubleValue] / 1000.0;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *dateString = [formatter stringFromDate: date];
// NSLog(@"服务器返回的时间戳对应的时间是:%@",dateString);
return dateString;
}
//UIRectCornerTopLeft | UIRectCornerTopRight .
+(CAShapeLayer*)setShapeLayer:(CGRect)rect andWithRectCorner:(UIRectCorner)corners andWithNumCorner:(CGFloat)Cornerfloat{
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:CGSizeMake(Cornerfloat, Cornerfloat)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
//
maskLayer.frame = rect;
//
maskLayer.path = maskPath.CGPath;
return maskLayer;
}
@end