Commit 2a07cff5 authored by 汪洋's avatar 汪洋

save progress

parent 5de016f1
......@@ -9,6 +9,10 @@
#import <Foundation/Foundation.h>
#import <Masonry/Masonry.h>
@interface GMJailbreak : NSObject
+ (BOOL)isJailbreak;
@end
@interface UIFont (GMBase)
+ (UIFont *)navigationFontWithSize:(NSInteger)size;
@end
......@@ -22,7 +26,7 @@
@property (nonatomic, strong) MASViewAttribute *mas_safeBottom;
@end
@interface MASConstraintMaker (GMAdditions)
- (void)mas_bottomToSuperView:(UIView *)view withHeight:(CGFloat)height;
@end
......@@ -28,7 +28,7 @@
@implementation UIView (GMAdditions)
- (MASViewAttribute *)mas_safeBottom {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0") && [self respondsToSelector:@selector(safeAreaLayoutGuide)]) {
return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
} else {
return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom];
......@@ -43,4 +43,39 @@
}
@end
@implementation GMJailbreak
+ (BOOL)isJailbreak {
//由于iOS9以后出现白名单,造成控制台不断打印警告
//所以换成以下方式判断
NSArray *paths = @[@"/Applications/Cydia.app",
@"/private/var/lib/apt/",
@"/private/var/lib/cydia",
@"/private/var/stash"];
for (NSString *path in paths) {
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) return YES;
}
FILE *bash = fopen("/bin/bash", "r");
if (bash != NULL) {
fclose(bash);
return YES;
}
NSString *path = [NSString stringWithFormat:@"/private/%@", [self stringWithUUID]];
if ([@"test" writeToFile : path atomically : YES encoding : NSUTF8StringEncoding error : NULL]) {
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
return YES;
}
return NO;
}
+ (NSString *)stringWithUUID {
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return (__bridge_transfer NSString *)string;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment