├── .gitignore ├── AKTKit ├── ARC_File │ ├── AKTCategory │ │ ├── AKTCategory.h │ │ ├── Foundation+Akt │ │ │ ├── NSArray+AKTArray.h │ │ │ ├── NSArray+AKTArray.m │ │ │ ├── NSDictionary+AKTDic.h │ │ │ ├── NSDictionary+AKTDic.m │ │ │ ├── NSFileManager+AKTFileManager.h │ │ │ ├── NSFileManager+AKTFileManager.m │ │ │ ├── NSObject+AKT.h │ │ │ ├── NSObject+AKT.m │ │ │ ├── NSString+AKTFilePath.h │ │ │ └── NSString+AKTFilePath.m │ │ └── UIkit+Akt │ │ │ ├── UIImage+AKT.h │ │ │ ├── UIImage+AKT.m │ │ │ ├── UIImageView+AKT.h │ │ │ ├── UIImageView+AKT.m │ │ │ ├── UILabel+Akt.h │ │ │ ├── UILabel+Akt.m │ │ │ ├── UIView+AKT.h │ │ │ └── UIView+AKT.m │ ├── AKTClass │ │ └── AKTUI │ │ │ ├── AKTImagePicker.h │ │ │ ├── AKTImagePicker.m │ │ │ ├── AKTNavitationController │ │ │ ├── AKTInteractivePop.h │ │ │ ├── AKTInteractivePop.m │ │ │ ├── AKTNaviPopAnimation.h │ │ │ ├── AKTNaviPopAnimation.m │ │ │ ├── AKTNaviPushAnimation.h │ │ │ ├── AKTNaviPushAnimation.m │ │ │ ├── AKTNavigationController.h │ │ │ └── AKTNavigationController.m │ │ │ ├── AKTScrollView.h │ │ │ ├── AKTScrollView.m │ │ │ ├── AKTTouchExtendView.h │ │ │ ├── AKTTouchExtendView.m │ │ │ ├── AKTUI.h │ │ │ └── AKTViewController │ │ │ ├── AKTDismissVCAnimation.h │ │ │ ├── AKTDismissVCAnimation.m │ │ │ ├── AKTInteractiveDismiss.h │ │ │ ├── AKTInteractiveDismiss.m │ │ │ ├── AKTNavigationBar.h │ │ │ ├── AKTNavigationBar.m │ │ │ ├── AKTPresentVCAnimation.h │ │ │ ├── AKTPresentVCAnimation.m │ │ │ ├── AKTViewController.h │ │ │ └── AKTViewController.m │ ├── AKTKit.h │ ├── AKTLayout │ │ ├── AKTAttributeItem.h │ │ ├── AKTAttributeItem.m │ │ ├── AKTLayout.xmind │ │ ├── AKTLayoutAttribute.h │ │ ├── AKTLayoutAttribute.m │ │ ├── AKTLayoutShell.h │ │ ├── AKTLayoutShell.m │ │ ├── AKTReferenceConfiguration.h │ │ ├── AKTReferenceConfiguration.m │ │ ├── UIView+AKTLayout.h │ │ └── UIView+AKTLayout.m │ ├── AKTPublic.h │ └── AKTPublic.m └── MRC_File │ ├── UIView+ViewAttribute.h │ └── UIView+ViewAttribute.m ├── AKTLayout.podspec ├── Exmaples └── AKTLayoutExmaple │ ├── AKTLayoutExmaple.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ ├── HaoYang.xcuserdatad │ │ └── xcschemes │ │ │ ├── AKTLayoutExmaple.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── YaHaoo.xcuserdatad │ │ └── xcschemes │ │ ├── AKTLayoutExmaple.xcscheme │ │ └── xcschememanagement.plist │ ├── AKTLayoutExmaple.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── HaoYang.xcuserdatad │ │ └── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── YaHaoo.xcuserdatad │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ ├── AKTLayoutExmaple │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AKTLogo.imageset │ │ │ ├── AKTLogo.png │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── icon@2x.png │ │ │ └── icon@3x.png │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── ExampleAKTLayout.h │ ├── ExampleAKTLayout.m │ ├── ExampleAnima.h │ ├── ExampleAnima.m │ ├── ExampleCoverView.h │ ├── ExampleCoverView.m │ ├── ExampleMasonry.h │ ├── ExampleMasonry.m │ ├── ExamplePlayer+UIControls.h │ ├── ExamplePlayer+UIControls.m │ ├── ExamplePlayer.h │ ├── ExamplePlayer.m │ ├── ExamplePlayerPrivate.h │ ├── Images │ │ ├── AKT_Anima@2x.png │ │ ├── AKT_Example@2x.png │ │ ├── AKT_Header@2x.png │ │ ├── AKT_Test1@2x.png │ │ ├── AKT_Test2@2x.png │ │ ├── CH_Last@2x.png │ │ ├── CH_ListBig@2x.png │ │ ├── CH_ListLittle@2x.png │ │ ├── CH_Mode0@2x.png │ │ ├── CH_Mode1@2x.png │ │ ├── CH_Next@2x.png │ │ ├── CH_PauseBig@2x.png │ │ ├── CH_PauseLittle.png │ │ ├── CH_PlayBig@2x.png │ │ ├── CH_PlayLittle.png │ │ ├── Cover@2x.png │ │ ├── P_Back@2x.png │ │ ├── P_Navi.png │ │ ├── P_Rotate@2x.png │ │ ├── P_Stop@2x.png │ │ ├── over.jpg │ │ └── slider@2x.png │ ├── Info.plist │ ├── NavigationController.h │ ├── NavigationController.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m │ ├── Podfile │ └── README.md ├── Imgs ├── AKTLayout.jpg ├── AKTLayoutUpdate.jpg ├── AutoLayout.gif ├── Demo │ ├── Demo1.gif │ ├── Demo2.gif │ └── reference.png ├── addLayout.jpg ├── animation.gif ├── architecture.jpg ├── compare.jpg ├── memory.jpg ├── orientation.gif ├── reference.jpg ├── screenShot.jpg ├── timeCost.jpg └── updateLayout.jpg ├── LICENSE ├── README.md └── Test ├── Test.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ ├── HaoYang.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── Test.xcscheme │ │ └── xcschememanagement.plist │ └── YaHaoo.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── Test.xcscheme │ └── xcschememanagement.plist └── Test ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AKTLogo.imageset │ ├── AKTLogo.png │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── Masonry ├── Info.plist ├── MASCompositeConstraint.h ├── MASCompositeConstraint.m ├── MASConstraint+Private.h ├── MASConstraint.h ├── MASConstraint.m ├── MASConstraintMaker.h ├── MASConstraintMaker.m ├── MASLayoutConstraint.h ├── MASLayoutConstraint.m ├── MASUtilities.h ├── MASViewAttribute.h ├── MASViewAttribute.m ├── MASViewConstraint.h ├── MASViewConstraint.m ├── Masonry.h ├── NSArray+MASAdditions.h ├── NSArray+MASAdditions.m ├── NSArray+MASShorthandAdditions.h ├── NSLayoutConstraint+MASDebugAdditions.h ├── NSLayoutConstraint+MASDebugAdditions.m ├── View+MASAdditions.h ├── View+MASAdditions.m ├── View+MASShorthandAdditions.h ├── ViewController+MASAdditions.h └── ViewController+MASAdditions.m ├── ViewController.h ├── ViewController.m ├── ViewController2.h ├── ViewController2.m └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | UserInterfaceState.xcuserstate 2 | Exmaples/AKTLayoutExmaple/Pods 3 | 4 | Podfile.lock 5 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/AKTCategory.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTCategory.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/8. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #ifndef AKTCategory_h 10 | #define AKTCategory_h 11 | #import "NSFileManager+AKTFileManager.h" 12 | #import "NSObject+AKT.h" 13 | #import "NSString+AKTFilePath.h" 14 | #import "UILabel+Akt.h" 15 | #import "UIView+AKT.h" 16 | #import "UIImage+AKT.h" 17 | #endif /* AKTCategory_h */ 18 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSArray+AKTArray.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+AKTArray.h 3 | // ting 4 | // 5 | // Created by HaoYang on 16/9/5. 6 | // Copyright © 2016年 ximalaya Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (AKTArray) 12 | - (id)objectMaybeAtIndex:(NSUInteger)index; 13 | @end 14 | 15 | @interface NSMutableArray (AKTMutableArray) 16 | - (void)addOptionalObject:(id)object; 17 | 18 | - (void)insertOptionalObjet:(id)object maybeAtIndex:(NSUInteger)index; 19 | 20 | - (void)removeObjectMaybeAtIndex:(NSUInteger)index; 21 | @end 22 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSArray+AKTArray.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+AKTArray.m 3 | // ting 4 | // 5 | // Created by HaoYang on 16/9/5. 6 | // Copyright © 2016年 ximalaya Inc. All rights reserved. 7 | // 8 | 9 | #import "NSArray+AKTArray.h" 10 | 11 | @implementation NSArray (AKTArray) 12 | - (id)objectMaybeAtIndex:(NSUInteger)index { 13 | if (index 10 | 11 | @interface NSDictionary (AKTDic) 12 | 13 | - (NSDictionary *)dictionaryMaybeForKey:(NSString *)key; 14 | 15 | - (NSArray *)arrayMaybeForKey:(NSString *)key; 16 | 17 | - (NSString *)stringMaybeForKey:(NSString *)key; 18 | 19 | - (NSNumber *)numberMaybeForKey:(NSString *)key; 20 | 21 | - (BOOL)boolMaybeForKey:(NSString *)key; 22 | 23 | - (NSInteger)integerMaybeForKey:(NSString *)key; 24 | 25 | - (double)doubleMaybeForKey:(NSString *)key; 26 | 27 | @end 28 | 29 | @interface NSMutableDictionary (AKTMutableDic) 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSDictionary+AKTDic.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+AKTDic.m 3 | // ting 4 | // 5 | // Created by HaoYang on 16/9/5. 6 | // Copyright © 2016年 ximalaya Inc. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+AKTDic.h" 10 | 11 | BOOL objExist(id obj) { 12 | if (obj) { 13 | if ([obj isKindOfClass:[NSNull class]]) { 14 | return NO; 15 | } 16 | return YES; 17 | } 18 | return NO; 19 | } 20 | 21 | @implementation NSDictionary (AKTDic) 22 | - (NSDictionary *)dictionaryMaybeForKey:(NSString *)key { 23 | if (!key) { 24 | return nil; 25 | } 26 | id obj = self[key]; 27 | return [obj isKindOfClass:[NSDictionary class]]? obj:nil; 28 | } 29 | 30 | - (NSArray *)arrayMaybeForKey:(NSString *)key { 31 | if (!key) { 32 | return nil; 33 | } 34 | id obj = self[key]; 35 | return [obj isKindOfClass:[NSArray class]]? obj:nil; 36 | } 37 | 38 | - (NSString *)stringMaybeForKey:(NSString *)key { 39 | if (!key) { 40 | return nil; 41 | } 42 | id obj = self[key]; 43 | return [obj isKindOfClass:[NSString class]]? obj:nil; 44 | } 45 | 46 | - (NSNumber *)numberMaybeForKey:(NSString *)key { 47 | if (!key) { 48 | return nil; 49 | } 50 | id obj = self[key]; 51 | return [obj isKindOfClass:[NSNumber class]]? obj:nil; 52 | } 53 | 54 | - (BOOL)boolMaybeForKey:(NSString *)key { 55 | if (!key) { 56 | return NO; 57 | } 58 | id obj = self[key]; 59 | NSNumber *num = [obj isKindOfClass:[NSNumber class]]? obj:nil; 60 | return [num boolValue]; 61 | } 62 | 63 | - (NSInteger)integerMaybeForKey:(NSString *)key { 64 | if (!key) { 65 | return 0; 66 | } 67 | id obj = self[key]; 68 | NSNumber *num = [obj isKindOfClass:[NSNumber class]]? obj:nil; 69 | return [num integerValue]; 70 | } 71 | 72 | - (double)doubleMaybeForKey:(NSString *)key { 73 | if (!key) { 74 | return 0; 75 | } 76 | id obj = self[key]; 77 | NSNumber *num = [obj isKindOfClass:[NSNumber class]]? obj:nil; 78 | return [num doubleValue]; 79 | } 80 | @end 81 | 82 | @implementation NSMutableDictionary (AKTMutableDic) 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSFileManager+AKTFileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSFileManager+AKTFileManager.h 3 | // Export 4 | // 5 | // Created by YaHaoo on 16/1/21. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, AKTFilePathCreateType) { 12 | AKTFilePathCreateType_BrandNew, 13 | AKTFilePathCreateType_UseExistingIfNeeded 14 | }; 15 | 16 | @interface NSFileManager (AKTFileManager) 17 | /* 18 | * Create file path from type (if the path exist we'll remove it and create new or just use the old, it depends on the type) 19 | */ 20 | + (NSString *)aktCreateDirectoryAtPath:(NSString *)path withType:(AKTFilePathCreateType)type error:(NSError **)error; 21 | 22 | /* 23 | * Create file from type (if the path exist we'll remove it and create new or just use the old, it depends on the type) 24 | */ 25 | + (NSString *)aktCreateFileAtPath:(NSString *)path withType:(AKTFilePathCreateType)type error:(NSError **)error; 26 | @end 27 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSFileManager+AKTFileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSFileManager+AKTFileManager.m 3 | // Export 4 | // 5 | // Created by YaHaoo on 16/1/21. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "NSFileManager+AKTFileManager.h" 10 | 11 | @implementation NSFileManager (AKTFileManager) 12 | /* 13 | * Create file path from type (if the path exist we'll remove it and create new or just use the old, it depends on the type) 14 | */ 15 | + (NSString *)aktCreateDirectoryAtPath:(NSString *)path withType:(AKTFilePathCreateType)type error:(NSError **)error 16 | { 17 | NSFileManager *manager = [NSFileManager defaultManager]; 18 | switch (type) { 19 | case AKTFilePathCreateType_BrandNew: 20 | [manager removeItemAtPath:path error:error]; 21 | [manager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:error]; 22 | break; 23 | case AKTFilePathCreateType_UseExistingIfNeeded: 24 | { 25 | BOOL dir; 26 | BOOL b = [manager fileExistsAtPath:path isDirectory:&dir]; 27 | if (b == YES && dir == YES) { 28 | nil; 29 | }else{ 30 | [manager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:error]; 31 | } 32 | break; 33 | } 34 | default: 35 | break; 36 | } 37 | return path; 38 | } 39 | 40 | /* 41 | * Create file from type (if the path exist we'll remove it and create new or just use the old, it depends on the type) 42 | */ 43 | + (NSString *)aktCreateFileAtPath:(NSString *)path withType:(AKTFilePathCreateType)type error:(NSError **)error 44 | { 45 | NSFileManager *manager = [NSFileManager defaultManager]; 46 | switch (type) { 47 | case AKTFilePathCreateType_BrandNew: 48 | [manager removeItemAtPath:path error:error]; 49 | [manager createDirectoryAtPath:[path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil]; 50 | [manager createFileAtPath:path contents:nil attributes:nil]; 51 | break; 52 | case AKTFilePathCreateType_UseExistingIfNeeded: 53 | { 54 | BOOL dir; 55 | BOOL b = [manager fileExistsAtPath:path isDirectory:&dir]; 56 | if (b == YES && dir == NO) { 57 | nil; 58 | }else{ 59 | [manager createDirectoryAtPath:[path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil]; 60 | [manager createFileAtPath:path contents:nil attributes:nil]; 61 | } 62 | break; 63 | } 64 | default: 65 | break; 66 | } 67 | return path; 68 | } 69 | @end 70 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSObject+AKT.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+AKT.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/5. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface NSObject (AKT) 13 | /* 14 | * Method swizzle for instance 15 | * Exchange origne method to a new method 16 | */ 17 | + (BOOL)swizzleClass:(Class)cls fromMethod:(SEL)origneSelector toMethod:(SEL)newSelector; 18 | @end 19 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSObject+AKT.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+AKT.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/5. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "NSObject+AKT.h" 10 | 11 | @implementation NSObject (AKT) 12 | #pragma mark - runtime 13 | //|--------------------------------------------------------- 14 | /* 15 | * Method swizzle for instance 16 | * Exchange origne method to a new method 17 | */ 18 | + (BOOL)swizzleClass:(Class)cls fromMethod:(SEL)origneSelector toMethod:(SEL)newSelector { 19 | // Safty check 20 | if (!(cls && origneSelector && newSelector)) { 21 | return NO; 22 | } 23 | Method origneMethod = class_getInstanceMethod(cls, origneSelector); 24 | Method newMethod = class_getInstanceMethod(cls, newSelector); 25 | // If we can't get the values of newMethod and origneMethod, return NO for exit. 26 | if (!(origneMethod && newMethod)) { 27 | return NO; 28 | } 29 | // Exchange method. 30 | // method_exchangeImplementations(origneMethod, newMethod); 31 | IMP origneImp = class_getMethodImplementation(cls, origneSelector); 32 | IMP newImp = class_getMethodImplementation(cls, newSelector); 33 | class_replaceMethod(cls, origneSelector, newImp, method_getTypeEncoding(newMethod)); 34 | class_replaceMethod(cls, newSelector, origneImp, method_getTypeEncoding(origneMethod)); 35 | return YES; 36 | } 37 | @end 38 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSString+AKTFilePath.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+AKTFilePath.h 3 | // Export 4 | // 5 | // Created by YaHaoo on 16/1/21. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //--------------------Structs statement & globle variables...-------------------- 12 | /* 13 | * Relative path type enumeration 14 | */ 15 | typedef NS_ENUM(NSInteger, AKTFilePathRelativePathType) { 16 | AKTFilePathRelativePathType_MainBundle, 17 | AKTFilePathRelativePathType_Home, 18 | AKTFilePathRelativePathType_Documents, 19 | AKTFilePathRelativePathType_Library, 20 | AKTFilePathRelativePathType_Tmp, 21 | AKTFilePathRelativePathType_Library_Caches, 22 | AKTFilePathRelativePathType_Library_Preferences 23 | }; 24 | //-------------------- E.n.d -------------------->Structs statement & globle variables... 25 | 26 | @interface NSString (AKTFilePath) 27 | /* 28 | * Return corresponding absolute path according to the path type 29 | */ 30 | + (NSString *)aktFilePathWithType:(AKTFilePathRelativePathType)relativePathType; 31 | 32 | /* 33 | * Add path with path component 34 | */ 35 | - (NSString *(^)(NSString *))addPath; 36 | 37 | /* 38 | * Appent string 39 | * objStr could be NSString or NSNumber 40 | */ 41 | - (NSString *(^)(NSObject *objStr))add; 42 | 43 | /* 44 | * String match format 45 | * 字符串是否匹配格式 46 | */ 47 | - (BOOL)predicateWithFormat:(NSString *)format; 48 | 49 | /* 50 | * MD5 stirng. 51 | */ 52 | +(NSString *)md5:(NSString *)inPutText; 53 | @end 54 | 55 | 56 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/Foundation+Akt/NSString+AKTFilePath.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+AKTFilePath.m 3 | // Export 4 | // 5 | // Created by YaHaoo on 16/1/21. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "NSString+AKTFilePath.h" 10 | #import "CommonCrypto/CommonDigest.h" 11 | 12 | @implementation NSString (AKTFilePath) 13 | /* 14 | * Return corresponding absolute path according to path type 15 | */ 16 | + (NSString *)aktFilePathWithType:(AKTFilePathRelativePathType)relativePathType 17 | { 18 | NSString *path; 19 | switch (relativePathType) { 20 | case AKTFilePathRelativePathType_Documents: 21 | path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES).firstObject; 22 | break; 23 | case AKTFilePathRelativePathType_Home: 24 | path = NSHomeDirectory(); 25 | break; 26 | case AKTFilePathRelativePathType_Library: 27 | path = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask, YES).firstObject; 28 | break; 29 | case AKTFilePathRelativePathType_Library_Caches: 30 | path = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES).firstObject; 31 | break; 32 | case AKTFilePathRelativePathType_Library_Preferences: 33 | path = [NSString aktFilePathWithType:AKTFilePathRelativePathType_Library].addPath(@"Preferences"); 34 | break; 35 | case AKTFilePathRelativePathType_MainBundle: 36 | path = [[NSBundle mainBundle] bundlePath]; 37 | break; 38 | case AKTFilePathRelativePathType_Tmp: 39 | path = NSTemporaryDirectory(); 40 | break; 41 | default: 42 | break; 43 | } 44 | return path; 45 | } 46 | 47 | /* 48 | * Add path with path component 49 | */ 50 | - (NSString *(^)(NSString *))addPath 51 | { 52 | return ^NSString *(NSString *addPath) { 53 | return [self stringByAppendingString:[NSString stringWithFormat:@"/%@",addPath]]; 54 | }; 55 | } 56 | 57 | /* 58 | * Appent string 59 | */ 60 | - (NSString *(^)(NSObject *objStr))add 61 | { 62 | return ^NSString *(NSObject *objStr) { 63 | return [self stringByAppendingString:[NSString stringWithFormat:@"%@",objStr.description]]; 64 | }; 65 | } 66 | 67 | /* 68 | * String match format 69 | * 字符串是否匹配格式 70 | */ 71 | - (BOOL)predicateWithFormat:(NSString *)format { 72 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", format]; 73 | return [predicate evaluateWithObject:self]; 74 | } 75 | 76 | /* 77 | * MD5 stirng. 78 | */ 79 | +(NSString *)md5:(NSString *)inPutText { 80 | const char *cStr = [inPutText UTF8String]; 81 | unsigned char result[CC_MD5_DIGEST_LENGTH]; 82 | CC_MD5(cStr, (CC_LONG)strlen(cStr), result); 83 | return [[NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", 84 | result[0], result[1], result[2], result[3], 85 | result[4], result[5], result[6], result[7], 86 | result[8], result[9], result[10], result[11], 87 | result[12], result[13], result[14], result[15] 88 | ] lowercaseString]; 89 | } 90 | @end 91 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UIImage+AKT.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AKT.h 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (AKT) 12 | /* 13 | * Create image from color. 14 | * 从颜色创建图片 15 | * @color: The color of the image. 16 | * @color: 图片的颜色 17 | */ 18 | + (UIImage *)imageWithColor:(UIColor *)color; 19 | 20 | /* 21 | * The image trimming to the specified dimensions 22 | * 将图片修剪为指定尺寸 23 | * @img: original image 24 | * @img: 原始图片 25 | * @size: destinated size 26 | * @size: 目标size 27 | * @complete: complete invoke 28 | * @complete: 完成回调 29 | */ 30 | + (void)imageCutImage:(UIImage *)img toSize:(CGSize)size complete:(void(^)(UIImage *result))complete; 31 | @end 32 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UIImage+AKT.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AKT.m 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "UIImage+AKT.h" 10 | 11 | @implementation UIImage (AKT) 12 | /* 13 | * Create image from color. 14 | * 从颜色创建图片 15 | * @color: The color of the image. 16 | * @color: 图片的颜色 17 | */ 18 | + (UIImage *)imageWithColor:(UIColor *)color { 19 | UIGraphicsBeginImageContext(CGSizeMake(10, 10)); 20 | CGContextRef context = UIGraphicsGetCurrentContext(); 21 | CGContextSetFillColorWithColor(context, color.CGColor); 22 | CGContextFillRect(context, CGRectMake(0, 0, 10, 10)); 23 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); 24 | UIGraphicsEndImageContext(); 25 | return theImage; 26 | } 27 | 28 | /* 29 | * The image trimming to the specified dimensions 30 | * 将图片修剪为指定尺寸 31 | * @img: original image 32 | * @img: 原始图片 33 | * @size: destinated size unit:pixel 34 | * @size: 目标size 单位:像素 35 | * @complete: complete invoke 36 | * @complete: 完成回调 37 | */ 38 | + (void)imageCutImage:(UIImage *)img toSize:(CGSize)size complete:(void(^)(UIImage *result))complete { 39 | // aktDispatcher_global_add(^(AKTAsyncTaskInfo *taskInfo) { 40 | // [taskInfo setTaskOperation:^id{ 41 | // return nil; 42 | // }]; 43 | // }); 44 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 45 | UIImage *newImage; 46 | CGSize imgSize = img.size; 47 | CGPoint drawPoint; 48 | CGSize scaledSize; 49 | if (imgSize.width/imgSize.height < size.width/size.height) {//scale with width 50 | scaledSize = CGSizeMake(size.width, imgSize.height/(imgSize.width/size.width)); 51 | drawPoint.x = 0; 52 | drawPoint.y = - (scaledSize.height-size.height)/2; 53 | }else{//scale with height 54 | scaledSize = CGSizeMake(imgSize.width/(imgSize.height/size.height), size.height); 55 | drawPoint.y = 0; 56 | drawPoint.x = - (scaledSize.width-size.width)/2; 57 | } 58 | UIGraphicsBeginImageContext(size); 59 | [img drawInRect:CGRectMake(drawPoint.x, drawPoint.y, scaledSize.width, scaledSize.height)]; 60 | newImage = UIGraphicsGetImageFromCurrentImageContext(); 61 | UIGraphicsEndImageContext(); 62 | dispatch_async(dispatch_get_main_queue(), ^{ 63 | if (complete) { 64 | complete(newImage); 65 | } 66 | }); 67 | }); 68 | } 69 | @end 70 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UIImageView+AKT.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+AKT.h 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/5/28. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImageView (AKT) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UIImageView+AKT.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+AKT.m 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/5/28. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+AKT.h" 10 | #import "NSObject+AKT.h" 11 | #import "UIView+AKTLayout.h" 12 | 13 | @implementation UIImageView (AKT) 14 | #pragma mark - super method 15 | //|--------------------------------------------------------- 16 | /* 17 | * Do something before initialization. 18 | */ 19 | + (void)load { 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | // Exchange "setText:" to "aktText:" 23 | [UIImageView swizzleClass:[UIImageView class] fromMethod:@selector(setImage:) toMethod:@selector(aktImage:)]; 24 | }); 25 | } 26 | #pragma mark - property settings 27 | //|--------------------------------------------------------- 28 | /* 29 | * The method was exchaged to method "setImage:" in the initialization of a label. So when we call "aktImage:" in actually calling "setImage:". 30 | */ 31 | - (void)aktImage:(UIImage *)image { 32 | // Set image 33 | [self aktImage:image]; 34 | 35 | // Setting all of them to NO means that the frame cann't change, just return. 36 | if (self.adaptiveHeight == nil && self.adaptiveWidth == nil) { 37 | return; 38 | } 39 | if (self.adaptiveWidth.boolValue == NO && self.adaptiveHeight.boolValue == NO) { 40 | return; 41 | } 42 | [self sizeToFit]; 43 | // Update aktLayout 44 | [self setNeedAKTLayout]; 45 | } 46 | @end 47 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UILabel+Akt.h: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Akt.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/2/26. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UILabel (Akt) 12 | @property (strong, nonatomic) NSNumber *maxHeight; 13 | @property (strong, nonatomic) NSNumber *maxWidth; 14 | @end 15 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UILabel+Akt.m: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Akt.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/2/26. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | // import- 9 | // import-"models.h" 10 | #import "NSObject+AKT.h" 11 | // import-"views.h" 12 | #import "UILabel+Akt.h" 13 | #import "UIView+AKTLayout.h" 14 | #import "AKTPublic.h" 15 | 16 | //--------------------Structs statement, globle variables...-------------------- 17 | static char kAKTLabelMaxHeight; 18 | static char kAKTLabelMaxWidth; 19 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 20 | 21 | @implementation UILabel (Akt) 22 | #pragma mark - super method 23 | //|--------------------------------------------------------- 24 | /* 25 | * Do something before initialization. 26 | */ 27 | + (void)load { 28 | static dispatch_once_t onceToken; 29 | dispatch_once(&onceToken, ^{ 30 | // Exchange "setText:" to "aktText:" 31 | [UILabel swizzleClass:[UILabel class] fromMethod:@selector(setText:) toMethod:@selector(aktText:)]; 32 | [UILabel swizzleClass:[UILabel class] fromMethod:@selector(setNumberOfLines:) toMethod:@selector(setAKTNumberOfLines:)]; 33 | }); 34 | } 35 | #pragma mark - property settings 36 | //|--------------------------------------------------------- 37 | - (void)setMaxWidth:(NSNumber *)maxWidth { 38 | if ([maxWidth floatValue]<0) { 39 | return; 40 | } 41 | objc_setAssociatedObject(self, &kAKTLabelMaxWidth, maxWidth, OBJC_ASSOCIATION_RETAIN); 42 | self.text = self.text; 43 | } 44 | 45 | - (NSNumber *)maxWidth { 46 | return objc_getAssociatedObject(self, &kAKTLabelMaxWidth); 47 | } 48 | 49 | - (void)setMaxHeight:(NSNumber *)maxHeight { 50 | if ([maxHeight floatValue]<0) { 51 | return; 52 | } 53 | objc_setAssociatedObject(self, &kAKTLabelMaxHeight, maxHeight, OBJC_ASSOCIATION_RETAIN); 54 | self.text = self.text; 55 | } 56 | 57 | - (NSNumber *)maxHeight { 58 | return objc_getAssociatedObject(self, &kAKTLabelMaxHeight); 59 | } 60 | 61 | /* 62 | * The method was exchaged to method "setText:" in the initialization of a label. So when we call "aktText:" in actually calling "setText:". 63 | */ 64 | - (void)aktText:(NSString *)text { 65 | // Set label's text 66 | [self aktText:text]; 67 | 68 | // Setting all of them to NO means that the frame cann't change, just return. 69 | if (self.adaptiveHeight == nil && self.adaptiveWidth == nil) { 70 | return; 71 | } 72 | if (self.adaptiveWidth.boolValue == NO && self.adaptiveHeight.boolValue == NO) { 73 | return; 74 | } 75 | 76 | // If all of values of them are YES we'll set the view's height to single line height and adaptiveHeight to NO by default. 77 | NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; 78 | style.lineBreakMode = self.lineBreakMode==NSLineBreakByCharWrapping? NSLineBreakByCharWrapping:NSLineBreakByWordWrapping; 79 | style.alignment = self.textAlignment; 80 | NSDictionary *attributeDic = @{NSFontAttributeName:self.font, NSParagraphStyleAttributeName:style}; 81 | void(^adaptiveHeight)() = ^(){ 82 | CGRect rec = [text boundingRectWithSize:(CGSizeMake(self.width, 9999)) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:attributeDic context:nil]; 83 | if(self.numberOfLines){// 设置了最大行数 84 | CGRect rec1 = [@" " boundingRectWithSize:(CGSizeMake(self.width, 9999)) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:attributeDic context:nil]; 85 | CGRect rec2 = [@" \n " boundingRectWithSize:(CGSizeMake(self.width, 9999)) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:attributeDic context:nil]; 86 | CGFloat height = rec1.size.height+(rec2.size.height-rec1.size.height)*(self.numberOfLines-1); 87 | self.height = rec.size.height>height? height:rec.size.height; 88 | }else{ 89 | if (self.maxHeight) { 90 | self.height = self.maxHeight.floatValue 10 | 11 | @interface UIView (AKT) 12 | /* 13 | * Shake view animation 14 | */ 15 | + (void)shakeAnimationWithView:(UIView *)view; 16 | 17 | /* 18 | * Set the view disable, when disable is equal to YES, the view will be uninteractive. 19 | */ 20 | - (void)viewWaiting:(BOOL)waiting; 21 | @end 22 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTCategory/UIkit+Akt/UIView+AKT.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AKT.m 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/8. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "UIView+AKT.h" 10 | #import "AKTKit.h" 11 | 12 | @implementation UIView (AKT) 13 | /* 14 | * Shake view animation 15 | */ 16 | + (void)shakeAnimationWithView:(UIView *)view 17 | { 18 | CGRect rec = view.frame; 19 | view.frame = CGRectMake(view.frame.origin.x+20, view.frame.origin.y, view.frame.size.width, view.frame.size.height); 20 | [UIView animateWithDuration:.5f delay:0 usingSpringWithDamping:.02f initialSpringVelocity:0.001f options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ 21 | view.frame = rec; 22 | } completion:^(BOOL finished) { 23 | nil; 24 | }]; 25 | } 26 | 27 | /* 28 | * Set the view disable, when disable is equal to YES, the view will be uninteractive. 29 | */ 30 | - (void)viewWaiting:(BOOL)waiting { 31 | UIView *view = [self viewWithTag:111111]; 32 | if (waiting) { 33 | if (view) { 34 | return; 35 | } 36 | self.layer.masksToBounds = YES; 37 | UIView *mask = [UIView new]; 38 | [self addSubview:mask]; 39 | mask.backgroundColor = mAKT_Color_Color(255, 255, 255, .5); 40 | mask.frame = self.bounds; 41 | mask.tag = 111111; 42 | mask.alpha = 0; 43 | [UIView animateWithDuration:.15 animations:^{ 44 | mask.alpha = 1; 45 | }]; 46 | self.userInteractionEnabled = NO; 47 | return; 48 | } 49 | if (!view) { 50 | return; 51 | } 52 | [UIView animateWithDuration:.15 animations:^{ 53 | view.alpha = 0; 54 | } completion:^(BOOL finished) { 55 | [view removeFromSuperview]; 56 | self.userInteractionEnabled = YES; 57 | }]; 58 | } 59 | @end 60 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTImagePicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTImagePicker.h 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/11. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AKTImagePicker : NSObject 13 | //> Call this block when finished. 14 | //> 操作完成时回调此block 15 | @property (strong, nonatomic) void(^result)(BOOL cancled, UIImage *img); 16 | @property (assign, nonatomic) BOOL enableEditing; 17 | @property (assign, nonatomic) CGSize size; 18 | @property (strong, nonatomic) UIViewController *superVc; 19 | - (void)chooseFromLibrary; 20 | - (void)chooseFromPicture; 21 | - (void)chooseFromCamera; 22 | @end 23 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTImagePicker.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTImagePicker.m 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/11. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "AKTImagePicker.h" 10 | #import "AKTPublic.h" 11 | #import "UIImage+AKT.h" 12 | 13 | @interface AKTImagePicker () 14 | @property (strong, nonatomic) UIImagePickerController *vc; 15 | @end 16 | @implementation AKTImagePicker 17 | #pragma mark - life cycle 18 | //|--------------------------------------------------------- 19 | - (instancetype)init 20 | { 21 | self = [super init]; 22 | if (self) { 23 | [self initialize]; 24 | } 25 | return self; 26 | } 27 | #pragma mark - view settings 28 | //|--------------------------------------------------------- 29 | - (void)chooseFromLibrary { 30 | [self.vc setSourceType:(UIImagePickerControllerSourceTypePhotoLibrary)]; 31 | self.vc.allowsEditing = self.enableEditing; 32 | if(self.superVc) [self.superVc presentViewController:self.vc animated:YES completion:nil]; 33 | } 34 | - (void)chooseFromPicture { 35 | [self.vc setSourceType:(UIImagePickerControllerSourceTypeSavedPhotosAlbum)]; 36 | self.vc.allowsEditing = self.enableEditing; 37 | if(self.superVc) [self.superVc presentViewController:self.vc animated:YES completion:nil]; 38 | } 39 | - (void)chooseFromCamera { 40 | [self.vc setSourceType:(UIImagePickerControllerSourceTypeCamera)]; 41 | self.vc.allowsEditing = self.enableEditing; 42 | if(self.superVc) [self.superVc presentViewController:self.vc animated:YES completion:nil]; 43 | } 44 | #pragma mark - model settings 45 | //|--------------------------------------------------------- 46 | - (void)initialize { 47 | UIImagePickerController *ipc = [[UIImagePickerController alloc]init]; 48 | self.vc = ipc; 49 | ipc.delegate = self; 50 | self.size = CGSizeMake(FLT_MAX, FLT_MAX); 51 | } 52 | #pragma mark - delegate 53 | //|--------------------------------------------------------- 54 | /* 55 | * Finish choosing a image. 56 | * 图片选择完成 57 | */ 58 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 59 | { 60 | // mAKT_Log(@"%@",info); 61 | if (self.result) { 62 | UIImage *img = self.enableEditing? info[UIImagePickerControllerEditedImage]:info[UIImagePickerControllerOriginalImage]; 63 | if (self.size.width 10 | 11 | @class AKTNavigationController; 12 | @interface AKTInteractivePop : UIPercentDrivenInteractiveTransition 13 | @property (assign, nonatomic) BOOL isInteracting; 14 | @property (assign, nonatomic) BOOL userInterfaceInteractive; 15 | - (id)initWithViewController:(AKTNavigationController *)vc; 16 | @end 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTInteractivePop.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTInteractivePop.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/7. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTInteractivePop.h" 10 | #import "AKTPublic.h" 11 | #import "AKTNavigationController.h" 12 | 13 | @interface AKTInteractivePop () 14 | @property (weak, nonatomic) AKTNavigationController *rootVC; 15 | @property (strong, nonatomic) UIPanGestureRecognizer *pan; 16 | @property (assign, nonatomic) CGFloat percent; 17 | @end 18 | @implementation AKTInteractivePop 19 | #pragma mark - life cycle 20 | //|--------------------------------------------------------- 21 | - (instancetype)initWithViewController:(AKTNavigationController *)vc 22 | { 23 | self = [super init]; 24 | if (self) { 25 | self.rootVC = vc; 26 | [self initialize]; 27 | } 28 | return self; 29 | } 30 | #pragma mark - property settings 31 | //|--------------------------------------------------------- 32 | - (UIPanGestureRecognizer *)pan { 33 | if (_pan == nil) { 34 | _pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)]; 35 | [self.rootVC.view addGestureRecognizer:_pan]; 36 | _pan.delegate = self; 37 | _userInterfaceInteractive = YES; 38 | } 39 | return _pan; 40 | } 41 | 42 | - (void)setUserInterfaceInteractive:(BOOL)userInterfaceInteractive { 43 | _userInterfaceInteractive = userInterfaceInteractive; 44 | self.pan.enabled = userInterfaceInteractive; 45 | } 46 | #pragma mark - universal methods 47 | //|--------------------------------------------------------- 48 | - (void)initialize { 49 | _pan = self.pan; 50 | } 51 | #pragma mark - click events 52 | //|--------------------------------------------------------- 53 | - (void)pan:(UIPanGestureRecognizer *)pan { 54 | CGPoint point = [pan translationInView:self.rootVC.view]; 55 | if (pan.state == UIGestureRecognizerStateBegan) { 56 | self.isInteracting = YES; 57 | [self.rootVC popViewControllerAnimated:YES]; 58 | }else if(pan.state == UIGestureRecognizerStateChanged) { 59 | if (point.x>0) { 60 | self.percent = (.15*point.x/mAKT_SCREENWITTH); 61 | [self updateInteractiveTransition:self.percent]; 62 | } 63 | }else if(pan.state == UIGestureRecognizerStateEnded || pan.state == UIGestureRecognizerStateFailed || pan.state == UIGestureRecognizerStateCancelled) { 64 | if (self.percent>.07) { 65 | self.completionSpeed = .8; 66 | [self finishInteractiveTransition]; 67 | }else{ 68 | self.completionSpeed = 0.08; 69 | [self cancelInteractiveTransition]; 70 | } 71 | self.isInteracting = NO; 72 | } 73 | } 74 | #pragma mark - delegate 75 | //|--------------------------------------------------------- 76 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 77 | if (self.rootVC.isAnimating) { 78 | return NO; 79 | } 80 | /** 81 | * 这里有两个条件不允许手势执行,1、当前控制器为根控制器;2、如果这个push、pop动画正在执行(私有属性) 82 | */ 83 | return self.rootVC.viewControllers.count>1? YES:NO; 84 | } 85 | @end 86 | 87 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNaviPopAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNaviPopAnimation.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "AKTPublic.h" 12 | 13 | @class AKTNavigationController; 14 | @interface AKTNaviPopAnimation : NSObject 15 | - (instancetype)initWithNv:(AKTNavigationController *)nv; 16 | @end 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNaviPopAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNaviPopAnimation.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTNaviPopAnimation.h" 10 | #import "AKTDismissVCAnimation.h" 11 | #import "AKTViewController.h" 12 | #import "UIView+AKTLayout.h" 13 | #import "AKTNavigationController.h" 14 | 15 | @interface AKTNaviPopAnimation () 16 | @property (weak, nonatomic) AKTNavigationController *nv; 17 | @end 18 | @implementation AKTNaviPopAnimation 19 | - (instancetype)initWithNv:(AKTNavigationController *)nv 20 | { 21 | self = [super init]; 22 | if (self) { 23 | self.nv = nv; 24 | } 25 | return self; 26 | } 27 | // This is used for percent driven interactive transitions, as well as for container controllers that have companion animations that might need to 28 | // synchronize with the main animation. 29 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext { 30 | return kTimeinterval+.1; 31 | } 32 | // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. 33 | - (void)animateTransition:(id )transitionContext { 34 | self.nv.isAnimating = YES; 35 | UIView *container = transitionContext.containerView; 36 | UIViewController *fromVc = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 37 | UIViewController *toVc = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 38 | [container addSubview:toVc.view]; 39 | [container addSubview:fromVc.view]; 40 | if ([toVc respondsToSelector:@selector(orientation:)]) { 41 | AKTViewController *vc = (id)toVc; 42 | [vc orientation: vc.interfaceOrientation]; 43 | } 44 | BOOL b = [fromVc isKindOfClass:[AKTViewController class]] && [toVc isKindOfClass:[AKTViewController class]]; 45 | AKTViewController *fVc = (id)fromVc; 46 | AKTViewController *tVc = (id)toVc; 47 | if (b) { 48 | fVc = (id)fromVc; 49 | tVc = (id)toVc; 50 | [container addSubview:tVc.naviBar]; 51 | [container addSubview:fVc.naviBar]; 52 | tVc.naviBar.alpha = 0; 53 | } 54 | 55 | fromVc.view.frame = CGRectMake(0, 0, fromVc.view.width, fromVc.view.height); 56 | toVc.view.transform = CGAffineTransformMakeScale(.96, .96); 57 | toVc.view.alpha = .8; 58 | NSTimeInterval duration = [self transitionDuration:transitionContext]; 59 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:1.f initialSpringVelocity:0.5f options:0 animations:^{ 60 | fromVc.view.frame = CGRectMake(fromVc.view.width, 0, fromVc.view.width, fromVc.view.height); 61 | toVc.view.alpha = 1; 62 | toVc.view.transform = CGAffineTransformIdentity; 63 | if (b) { 64 | fVc.naviBar.alpha = 0; 65 | tVc.naviBar.alpha = 1; 66 | } 67 | } completion:^(BOOL finished) { 68 | // 恢复缩放,因为需要还原初始状态,否则手势拖动取消时发生错误 69 | toVc.view.transform = CGAffineTransformIdentity; 70 | // 必须将fromVC的view位置复位,否则在取消状态下会出现显示错误 71 | fromVc.view.frame = CGRectMake(0, 0, fromVc.view.width, fromVc.view.height); 72 | if (b) { 73 | [fVc.view addSubview:fVc.naviBar]; 74 | [tVc.view addSubview:tVc.naviBar]; 75 | fVc.naviBar.alpha = 1; 76 | tVc.naviBar.alpha = 1; 77 | } 78 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; 79 | self.nv.isAnimating = NO; 80 | }]; 81 | } 82 | @end 83 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNaviPushAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNaviPushAnimation.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "AKTPublic.h" 12 | 13 | @class AKTNavigationController; 14 | @interface AKTNaviPushAnimation : NSObject 15 | - (instancetype)initWithNv:(AKTNavigationController *)nv; 16 | @end 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNaviPushAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNaviPushAnimation.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTNaviPushAnimation.h" 10 | #import "AKTDismissVCAnimation.h" 11 | #import "AKTViewController.h" 12 | #import "AKTNavigationController.h" 13 | #import "UIView+AKTLayout.h" 14 | 15 | @interface AKTNaviPushAnimation () 16 | @property (weak, nonatomic) AKTNavigationController *nv; 17 | @end 18 | @implementation AKTNaviPushAnimation 19 | - (instancetype)initWithNv:(AKTNavigationController *)nv 20 | { 21 | self = [super init]; 22 | if (self) { 23 | self.nv = nv; 24 | } 25 | return self; 26 | } 27 | // This is used for percent driven interactive transitions, as well as for container controllers that have companion animations that might need to 28 | // synchronize with the main animation. 29 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext { 30 | return kTimeinterval; 31 | } 32 | // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. 33 | - (void)animateTransition:(id )transitionContext { 34 | self.nv.isAnimating = YES; 35 | UIView *container = transitionContext.containerView; 36 | UIViewController *fromVc = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 37 | UIViewController *toVc = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 38 | if ([toVc isKindOfClass:[AKTViewController class]]) { 39 | AKTViewController *vc = (id)toVc; 40 | [vc orientation: fromVc.interfaceOrientation]; 41 | } 42 | [container addSubview:fromVc.view]; 43 | [container addSubview:toVc.view]; 44 | BOOL b = [fromVc isKindOfClass:[AKTViewController class]] && [toVc isKindOfClass:[AKTViewController class]]; 45 | AKTViewController *fVc = (id)fromVc; 46 | AKTViewController *tVc = (id)toVc; 47 | if (b) { 48 | fVc = (id)fromVc; 49 | tVc = (id)toVc; 50 | [container addSubview:tVc.naviBar]; 51 | [container addSubview:fVc.naviBar]; 52 | tVc.naviBar.alpha = 0; 53 | } 54 | 55 | toVc.view.frame = CGRectMake(toVc.view.width, 0, toVc.view.width, toVc.view.height); 56 | NSTimeInterval duration = [self transitionDuration:transitionContext]; 57 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:1.f initialSpringVelocity:0.5f options:0 animations:^{ 58 | toVc.view.frame = CGRectMake(0, 0, toVc.view.width, toVc.view.height); 59 | fromVc.view.transform = CGAffineTransformMakeScale(.96, .96); 60 | fromVc.view.alpha = .8; 61 | if (b) { 62 | fVc.naviBar.alpha = 0; 63 | tVc.naviBar.alpha = 1; 64 | } 65 | } completion:^(BOOL finished) { 66 | fromVc.view.alpha = 1; 67 | fromVc.view.transform = CGAffineTransformIdentity; 68 | if (b) { 69 | [fVc.view addSubview:fVc.naviBar]; 70 | [tVc.view addSubview:tVc.naviBar]; 71 | fVc.naviBar.alpha = 1; 72 | tVc.naviBar.alpha = 1; 73 | } 74 | [transitionContext completeTransition:YES]; 75 | self.nv.isAnimating = NO; 76 | }]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNavigationController.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AKTViewController.h" 11 | 12 | @interface AKTNavigationController : UINavigationController 13 | @property (assign, nonatomic) BOOL isAnimating; 14 | @property (assign, nonatomic) BOOL interactiveGestureEnable; 15 | /* 16 | * 旋转屏幕之后返回上一个界面时需要手动设置一下界面,有可能进入前和退出时方向时不一致的 17 | */ 18 | - (void)orientation:(UIInterfaceOrientation)toInterfaceOrientation; 19 | @end 20 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTNavitationController/AKTNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNavigationController.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTNavigationController.h" 10 | #import "AKTNaviPopAnimation.h" 11 | #import "AKTNaviPushAnimation.h" 12 | #import "AKTInteractivePop.h" 13 | #import "AKTViewController.h" 14 | 15 | @interface AKTNavigationController () 16 | @property (strong, nonatomic) AKTNaviPopAnimation *popAnimation; 17 | @property (strong, nonatomic) AKTNaviPushAnimation *pushAnimation; 18 | @property (strong, nonatomic) AKTInteractivePop *interactivePop; 19 | @end 20 | @implementation AKTNavigationController 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Don't adjust scrollView inset automatically. 24 | // 不自动调整scrollview插入值 25 | self.automaticallyAdjustsScrollViewInsets = NO; 26 | self.delegate = self; 27 | _interactivePop = self.interactivePop; 28 | self.interactivePopGestureRecognizer.enabled = NO; 29 | self.automaticallyAdjustsScrollViewInsets = NO; 30 | self.navigationBarHidden = YES; 31 | } 32 | #pragma mark - property settings 33 | //|--------------------------------------------------------- 34 | - (AKTNaviPushAnimation *)pushAnimation { 35 | if (_pushAnimation == nil) { 36 | _pushAnimation = [[AKTNaviPushAnimation alloc]initWithNv:self]; 37 | } 38 | return _pushAnimation; 39 | } 40 | 41 | - (AKTNaviPopAnimation *)popAnimation { 42 | if (_popAnimation == nil) { 43 | _popAnimation = [[AKTNaviPopAnimation alloc]initWithNv:self]; 44 | } 45 | return _popAnimation; 46 | } 47 | 48 | - (AKTInteractivePop *)interactivePop { 49 | if (_interactivePop == nil) { 50 | _interactivePop = [[AKTInteractivePop alloc]initWithViewController:self]; 51 | } 52 | return _interactivePop; 53 | } 54 | 55 | - (void)setInteractiveGestureEnable:(BOOL)interactiveGestureEnable { 56 | _interactiveGestureEnable = interactiveGestureEnable; 57 | self.interactivePop.userInterfaceInteractive = interactiveGestureEnable; 58 | } 59 | #pragma mark - view settings 60 | //|--------------------------------------------------------- 61 | /* 62 | * 旋转屏幕之后返回上一个界面时需要手动设置一下界面,有可能进入前和退出时方向时不一致的 63 | */ 64 | - (void)orientation:(UIInterfaceOrientation)toInterfaceOrientation { 65 | CGFloat width = mAKT_Device_Width; 66 | CGFloat height = mAKT_Device_Height; 67 | switch (toInterfaceOrientation) { 68 | case UIInterfaceOrientationPortrait: 69 | self.view.frame = CGRectMake(0, 0, width, height); 70 | break; 71 | case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: 72 | self.view.frame = CGRectMake(0, 0, height, width); 73 | break; 74 | default: 75 | break; 76 | } 77 | } 78 | #pragma mark - delegate 79 | //|--------------------------------------------------------- 80 | - (nullable id )navigationController:(UINavigationController *)navigationController 81 | animationControllerForOperation:(UINavigationControllerOperation)operation 82 | fromViewController:(UIViewController *)fromVC 83 | toViewController:(UIViewController *)toVC NS_AVAILABLE_IOS(7_0) { 84 | if (operation == UINavigationControllerOperationPush) { 85 | return self.pushAnimation; 86 | }else if(operation == UINavigationControllerOperationPop){ 87 | return self.popAnimation; 88 | } 89 | return nil; 90 | } 91 | 92 | - (nullable id )navigationController:(UINavigationController *)navigationController 93 | interactionControllerForAnimationController:(id ) animationController NS_AVAILABLE_IOS(7_0) { 94 | if([animationController isKindOfClass:[AKTNaviPopAnimation class]]){ 95 | return self.interactivePop.isInteracting? self.interactivePop:nil; 96 | } 97 | return nil; 98 | } 99 | @end 100 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTSrollView.h 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AKTScrollView : UIScrollView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTSrollView.m 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "AKTScrollView.h" 10 | 11 | @implementation AKTScrollView 12 | - (BOOL)touchesShouldCancelInContentView:(UIView *)view { 13 | return YES; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTTouchExtendView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTTouchExtendView.h 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AKTTouchExtendView : UIView 12 | - (id)initWithVeiw:(UIView *)view; 13 | 14 | /** 15 | * 创建一个触摸扩展视图 16 | * 17 | * @param bindView 需要被扩展的view,view 需要被加入到父视图 18 | * @param inset 相对于需要被扩展的view的边缘的距离 19 | */ 20 | + (void)touchExtendForView:(UIView *)bindView extendInset:(UIEdgeInsets)inset; 21 | @end 22 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTTouchExtendView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTTouchExtendView.m 3 | // Coolhear 3D Player 4 | // 5 | // Created by YaHaoo on 16/4/10. 6 | // Copyright © 2016年 CoolHear. All rights reserved. 7 | // 8 | 9 | #import "AKTTouchExtendView.h" 10 | #import "UIView+AKTLayout.h" 11 | 12 | @interface AKTTouchExtendView() 13 | @property (weak, nonatomic) UIView *view; 14 | @end 15 | @implementation AKTTouchExtendView 16 | 17 | /* 18 | // Only override drawRect: if you perform custom drawing. 19 | // An empty implementation adversely affects performance during animation. 20 | - (void)drawRect:(CGRect)rect { 21 | // Drawing code 22 | } 23 | */ 24 | - (id)initWithVeiw:(UIView *)view 25 | { 26 | self = [super init]; 27 | if (self) { 28 | self.view = view; 29 | } 30 | return self; 31 | } 32 | 33 | /** 34 | * 创建一个触摸扩展视图 35 | * 36 | * @param bindView 需要被扩展的view,view 需要被加入到父视图 37 | * @param inset 相对于需要被扩展的view的边缘的距离 38 | */ 39 | + (void)touchExtendForView:(UIView *)bindView extendInset:(UIEdgeInsets)inset { 40 | UIView *touch = [[AKTTouchExtendView alloc]initWithVeiw:bindView]; 41 | [bindView.superview addSubview:touch]; 42 | touch.frame = CGRectMake(bindView.x-inset.left, bindView.y-inset.top, bindView.width+inset.left+inset.right, bindView.height+inset.top+inset.bottom); 43 | } 44 | 45 | - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event 46 | { 47 | if ([self pointInside:point withEvent:event] && self.alpha*100>0 && !self.hidden) { 48 | return self.view; 49 | }else{ 50 | return [super hitTest:point withEvent:event]; 51 | } 52 | } 53 | @end 54 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTUI.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTUI.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/7. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #ifndef AKTUI_h 10 | #define AKTUI_h 11 | #import "AKTNavigationController.h" 12 | #import "AKTViewController.h" 13 | #import "AKTScrollView.h" 14 | #import "AKTTouchExtendView.h" 15 | #import "AKTImagePicker.h" 16 | #endif /* AKTUI_h */ 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTDismissVCAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTPopVCAnimation.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | //--------------# Macro #-------------- 12 | #define kTimeinterval .5 13 | //--------------# E.n.d #--------------#>Macro 14 | @interface AKTDismissVCAnimation : NSObject 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTDismissVCAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTPopVCAnimation.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTDismissVCAnimation.h" 10 | #import "AKTPublic.h" 11 | #import "AKTViewController.h" 12 | #import "UIView+AKTLayout.h" 13 | 14 | @implementation AKTDismissVCAnimation 15 | #pragma mark - delegate 16 | //|--------------------------------------------------------- 17 | // This is used for percent driven interactive transitions, as well as for container controllers that have companion animations that might need to 18 | // synchronize with the main animation. 19 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext { 20 | return kTimeinterval; 21 | } 22 | 23 | // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. 24 | - (void)animateTransition:(id )transitionContext { 25 | UIView *container = transitionContext.containerView; 26 | UIViewController *fromVc = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 27 | UIViewController *toVc = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 28 | if ([toVc respondsToSelector:@selector(orientation:)]) { 29 | AKTViewController *vc = (id)toVc; 30 | [vc orientation: vc.interfaceOrientation]; 31 | } 32 | [container addSubview:toVc.view]; 33 | [container addSubview:fromVc.view]; 34 | fromVc.view.frame = CGRectMake(0, 0, mAKT_SCREENWITTH, mAKT_SCREENHEIGHT); 35 | toVc.view.transform = CGAffineTransformMakeScale(.96, .96); 36 | toVc.view.alpha = .8; 37 | NSTimeInterval duration = [self transitionDuration:transitionContext]; 38 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:1.f initialSpringVelocity:0.5f options:0 animations:^{ 39 | fromVc.view.frame = CGRectMake(0, mAKT_SCREENHEIGHT, mAKT_SCREENWITTH, mAKT_SCREENHEIGHT); 40 | toVc.view.alpha = 1; 41 | toVc.view.transform = CGAffineTransformIdentity; 42 | } completion:^(BOOL finished) { 43 | // 恢复缩放,因为需要还原初始状态,否则手势拖动取消时发生错误 44 | toVc.view.transform = CGAffineTransformIdentity; 45 | // 必须将fromVC的view位置复位,否则在取消状态下会出现显示错误 46 | fromVc.view.frame = CGRectMake(0, 0, fromVc.view.width, fromVc.view.height); 47 | if(![transitionContext transitionWasCancelled]){ 48 | // [fromVc.view removeFromSuperview]; 49 | } 50 | [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; 51 | }]; 52 | } 53 | @end 54 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTInteractiveDismiss.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTInteractiveDismiss.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AKTInteractiveDismiss : UIPercentDrivenInteractiveTransition 12 | @property (assign, nonatomic) BOOL isInteracting; 13 | @property (assign, nonatomic) BOOL userInterfaceInteractive; 14 | - (id)initWithViewController:(UIViewController *)vc; 15 | @end 16 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTInteractiveDismiss.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTInteractiveDismiss.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTInteractiveDismiss.h" 10 | #import "AKTPublic.h" 11 | @interface AKTInteractiveDismiss () 12 | @property (weak, nonatomic) UIViewController *rootVC; 13 | @property (strong, nonatomic) UIPanGestureRecognizer *pan; 14 | @property (assign, nonatomic) CGFloat percent; 15 | @end 16 | @implementation AKTInteractiveDismiss 17 | #pragma mark - life cycle 18 | //|--------------------------------------------------------- 19 | - (instancetype)initWithViewController:(UIViewController *)vc 20 | { 21 | self = [super init]; 22 | if (self) { 23 | self.rootVC = vc; 24 | [self initialize]; 25 | } 26 | return self; 27 | } 28 | #pragma mark - property settings 29 | //|--------------------------------------------------------- 30 | - (UIPanGestureRecognizer *)pan { 31 | if (_pan == nil) { 32 | _pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)]; 33 | [self.rootVC.view addGestureRecognizer:_pan]; 34 | _pan.delegate = self; 35 | _userInterfaceInteractive = YES; 36 | } 37 | return _pan; 38 | } 39 | 40 | - (void)setUserInterfaceInteractive:(BOOL)userInterfaceInteractive { 41 | _userInterfaceInteractive = userInterfaceInteractive; 42 | self.pan.enabled = userInterfaceInteractive; 43 | } 44 | #pragma mark - universal methods 45 | //|--------------------------------------------------------- 46 | - (void)initialize { 47 | _pan = self.pan; 48 | } 49 | #pragma mark - click events 50 | //|--------------------------------------------------------- 51 | - (void)pan:(UIPanGestureRecognizer *)pan { 52 | CGPoint point = [pan translationInView:self.rootVC.view]; 53 | if (pan.state == UIGestureRecognizerStateBegan) { 54 | self.isInteracting = YES; 55 | [self.rootVC dismissViewControllerAnimated:YES completion:nil]; 56 | }else if(pan.state == UIGestureRecognizerStateChanged) { 57 | if (point.y>0) { 58 | self.percent = (point.y/mAKT_SCREENWITTH); 59 | [self updateInteractiveTransition:self.percent]; 60 | } 61 | }else if(pan.state == UIGestureRecognizerStateEnded || pan.state == UIGestureRecognizerStateFailed || pan.state == UIGestureRecognizerStateCancelled) { 62 | if (self.percent>.07) { 63 | self.completionSpeed = .8; 64 | [self finishInteractiveTransition]; 65 | }else{ 66 | self.completionSpeed = 0.08; 67 | [self cancelInteractiveTransition]; 68 | } 69 | self.isInteracting = NO; 70 | } 71 | } 72 | #pragma mark - delegate 73 | //|--------------------------------------------------------- 74 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 75 | // The presence of the navigation controller, using navigation controller gestures 76 | // 存在导航控制器时,启用导航控制器手势 77 | if (self.rootVC.navigationController) { 78 | return NO; 79 | } 80 | // No navigation controller, their own gesture-enabled, and in the case has been presented. 81 | // 没有时启用自己手势,并且在已被推出的情况下 82 | if (self.rootVC.presentingViewController) { 83 | return YES; 84 | } 85 | return NO; 86 | } 87 | @end 88 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNavigationBar.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/7. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AKTNavigationBar : UIView 12 | @property (strong, nonatomic) UIImageView *naviBackgroundImg; 13 | @property (strong, nonatomic) UIButton *leftNaviBtn; 14 | @property (strong, nonatomic) UIButton *rightNaviBtn; 15 | @property (strong, nonatomic) UILabel *title; 16 | @end 17 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTNavigationBar.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/7. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTNavigationBar.h" 10 | #import "AKTPublic.h" 11 | #import "UIView+AKTLayout.h" 12 | 13 | @implementation AKTNavigationBar 14 | - (instancetype)init 15 | { 16 | self = [super init]; 17 | if (self) { 18 | self.frame = CGRectMake(0, 0, mAKT_SCREENWITTH, 64); 19 | } 20 | return self; 21 | } 22 | #pragma mark - super methods 23 | //|--------------------------------------------------------- 24 | - (void)layoutSubviews { 25 | [super layoutSubviews]; 26 | // Layout subviews 27 | CGFloat topHeight = mAKT_EQ(self.width, mAKT_Device_Width)? 20:0; 28 | self.naviBackgroundImg.frame = CGRectMake(0, 0, self.superview.width, 44+topHeight); 29 | self.leftNaviBtn.frame = CGRectMake(10, topHeight, 54, 44); 30 | self.rightNaviBtn.frame = CGRectMake(self.superview.width-54-10,topHeight, 54, 44); 31 | [self.title aktLayout:^(AKTLayoutShellAttribute *layout) { 32 | layout.centerX.equalTo(akt_view(self)); 33 | layout.left.equalTo(akt_value(64)); 34 | layout.top.equalTo(akt_view(self)).offset(topHeight); 35 | layout.height.equalTo(akt_value(44)); 36 | }]; 37 | } 38 | #pragma mark - property settings 39 | //|--------------------------------------------------------- 40 | - (UIImageView *)naviBackgroundImg { 41 | if (_naviBackgroundImg == nil) { 42 | _naviBackgroundImg = [UIImageView new]; 43 | [self addSubview:_naviBackgroundImg]; 44 | if (DEBUG_INFO_SHOW) { 45 | _naviBackgroundImg.backgroundColor = mAKT_Color_Random; 46 | } 47 | } 48 | return _naviBackgroundImg; 49 | } 50 | 51 | - (UIButton *)leftNaviBtn { 52 | if (_leftNaviBtn == nil) { 53 | _leftNaviBtn = [UIButton buttonWithType:(UIButtonTypeSystem)]; 54 | [self addSubview:_leftNaviBtn]; 55 | [_leftNaviBtn setTitleColor:mAKT_Color_Black forState:(UIControlStateNormal)]; 56 | [_leftNaviBtn.titleLabel setFont:mAKT_Font_18]; 57 | if (DEBUG_INFO_SHOW) { 58 | [_leftNaviBtn setBackgroundColor:mAKT_Color_Random]; 59 | } 60 | } 61 | return _leftNaviBtn; 62 | } 63 | 64 | - (UIButton *)rightNaviBtn { 65 | if (_rightNaviBtn == nil) { 66 | _rightNaviBtn = [UIButton buttonWithType:(UIButtonTypeSystem)]; 67 | [self addSubview:_rightNaviBtn]; 68 | [_rightNaviBtn setTitleColor:mAKT_Color_Black forState:(UIControlStateNormal)]; 69 | [_rightNaviBtn.titleLabel setFont:mAKT_Font_18]; 70 | if (DEBUG_INFO_SHOW) { 71 | [_rightNaviBtn setBackgroundColor:mAKT_Color_Random]; 72 | } 73 | } 74 | return _rightNaviBtn; 75 | } 76 | 77 | - (UILabel *)title { 78 | if (_title == nil) { 79 | _title = [UILabel new]; 80 | [self addSubview:_title]; 81 | [_title setFont:mAKT_Font_18]; 82 | [_title setTextColor:mAKT_Color_Black]; 83 | [_title setTextAlignment:(NSTextAlignmentCenter)]; 84 | if (DEBUG_INFO_SHOW) { 85 | _title.backgroundColor = mAKT_Color_Random; 86 | } 87 | } 88 | return _title; 89 | } 90 | @end 91 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTPresentVCAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTPresentVCAnimation.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface AKTPresentVCAnimation : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTPresentVCAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTPresentVCAnimation.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTPresentVCAnimation.h" 10 | #import "AKTPublic.h" 11 | #import "AKTDismissVCAnimation.h" 12 | #import "AKTViewController.h" 13 | 14 | @implementation AKTPresentVCAnimation 15 | #pragma mark - delegate 16 | //|--------------------------------------------------------- 17 | // This is used for percent driven interactive transitions, as well as for container controllers that have companion animations that might need to 18 | // synchronize with the main animation. 19 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext { 20 | return kTimeinterval; 21 | } 22 | 23 | // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. 24 | - (void)animateTransition:(id )transitionContext { 25 | UIView *container = transitionContext.containerView; 26 | UIViewController *fromVc = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 27 | UIViewController *toVc = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 28 | if ([toVc isKindOfClass:[AKTViewController class]]) { 29 | AKTViewController *vc = (id)toVc; 30 | [vc orientation: fromVc.interfaceOrientation]; 31 | } 32 | [container addSubview:fromVc.view]; 33 | [container addSubview:toVc.view]; 34 | toVc.view.frame = CGRectMake(0, mAKT_SCREENHEIGHT, mAKT_SCREENWITTH, mAKT_SCREENHEIGHT); 35 | NSTimeInterval duration = [self transitionDuration:transitionContext]; 36 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:1.f initialSpringVelocity:0.5f options:0 animations:^{ 37 | toVc.view.frame = CGRectMake(0, 0, mAKT_SCREENWITTH, mAKT_SCREENHEIGHT); 38 | fromVc.view.transform = CGAffineTransformMakeScale(.96, .96); 39 | fromVc.view.alpha = .8; 40 | } completion:^(BOOL finished) { 41 | fromVc.view.alpha = 1; 42 | fromVc.view.transform = CGAffineTransformIdentity; 43 | [transitionContext completeTransition:YES]; 44 | }]; 45 | } 46 | @end 47 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTViewController.h 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AKTNavigationBar.h" 11 | 12 | @interface AKTViewController : UIViewController 13 | @property (strong, nonatomic) AKTNavigationBar *naviBar; 14 | @property (assign, nonatomic) BOOL interactiveGestureEnable; 15 | - (void)orientation:(UIInterfaceOrientation)toInterfaceOrientation; 16 | 17 | /* 18 | * Current view controller was poped. 19 | */ 20 | - (void)viewControllerPoped; 21 | @end 22 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTClass/AKTUI/AKTViewController/AKTViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTViewController.m 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/4/6. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AKTViewController.h" 10 | #import "AKTPublic.h" 11 | #import "AKTDismissVCAnimation.h" 12 | #import "AKTPresentVCAnimation.h" 13 | #import "AKTInteractiveDismiss.h" 14 | #import "UIView+AKTLayout.h" 15 | #import "objc/runtime.h" 16 | 17 | //--------------------Structs statement, globle variables...-------------------- 18 | static const char *observer = "observer"; 19 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 20 | @interface AKTViewController () 21 | @property (strong, nonatomic) AKTPresentVCAnimation *pAnimation; 22 | @property (strong, nonatomic) AKTDismissVCAnimation *dAnimation; 23 | @property (strong, nonatomic) AKTInteractiveDismiss *interactiveDismiss; 24 | @end 25 | @implementation AKTViewController 26 | #pragma mark - life cycle 27 | //|--------------------------------------------------------- 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | // Don't adjust scrollView inset automatically. 31 | // 不自动调整scrollview插入值 32 | self.automaticallyAdjustsScrollViewInsets = NO; 33 | // Add observer for layout event. 34 | 35 | self.transitioningDelegate = self; 36 | _interactiveDismiss = self.interactiveDismiss; 37 | // Setup naviBar 38 | _naviBar = self.naviBar; 39 | } 40 | 41 | - (void)viewWillDisappear:(BOOL)animated { 42 | [super viewWillDisappear:animated]; 43 | if (self.navigationController && ![self.navigationController.viewControllers containsObject:self]) { 44 | [self viewControllerPoped]; 45 | } 46 | } 47 | 48 | - (void)dealloc 49 | { 50 | if (objc_getAssociatedObject(self, observer)) { 51 | [self.view removeObserver:self forKeyPath:@"frame"]; 52 | } 53 | } 54 | #pragma mark - property settings 55 | //|--------------------------------------------------------- 56 | - (void)setInteractiveGestureEnable:(BOOL)interactiveGestureEnable { 57 | _interactiveGestureEnable = interactiveGestureEnable; 58 | self.interactiveDismiss.userInterfaceInteractive = interactiveGestureEnable; 59 | } 60 | 61 | #pragma mark - view methods 62 | //|--------------------------------------------------------- 63 | /* 64 | * Subviews need layout. 65 | */ 66 | - (void)viewDidLayoutSubviews { 67 | [super viewDidLayoutSubviews]; 68 | self.naviBar.width = self.view.width; 69 | if (self.view.width>self.view.height) { 70 | self.naviBar.height = 44; 71 | [[UIApplication sharedApplication] setStatusBarHidden:YES]; 72 | }else{ 73 | self.naviBar.height = 64; 74 | [[UIApplication sharedApplication] setStatusBarHidden:NO]; 75 | } 76 | [self.naviBar aktLayoutUpdate]; 77 | } 78 | 79 | 80 | /* 81 | * Current view controller was poped 82 | */ 83 | - (void)viewControllerPoped { 84 | 85 | } 86 | #pragma mark - view settings 87 | //|--------------------------------------------------------- 88 | /* 89 | * 旋转屏幕之后返回上一个界面时需要手动设置一下界面,有可能进入前和退出时方向时不一致的 90 | */ 91 | - (void)orientation:(UIInterfaceOrientation)toInterfaceOrientation { 92 | CGFloat width = mAKT_Device_Width; 93 | CGFloat height = mAKT_Device_Height; 94 | switch (toInterfaceOrientation) { 95 | case UIInterfaceOrientationPortrait: 96 | self.view.frame = CGRectMake(0, 0, width, height); 97 | break; 98 | case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: 99 | self.view.frame = CGRectMake(0, 0, height, width); 100 | break; 101 | default: 102 | break; 103 | } 104 | } 105 | #pragma mark - property settings 106 | //|--------------------------------------------------------- 107 | - (AKTPresentVCAnimation *)pAnimation { 108 | if (_pAnimation == nil) { 109 | _pAnimation = [AKTPresentVCAnimation new]; 110 | } 111 | return _pAnimation; 112 | } 113 | 114 | - (AKTDismissVCAnimation *)dAnimation { 115 | if (_dAnimation == nil) { 116 | _dAnimation = [AKTDismissVCAnimation new]; 117 | } 118 | return _dAnimation; 119 | } 120 | 121 | - (AKTInteractiveDismiss *)interactiveDismiss { 122 | if (_interactiveDismiss == nil) { 123 | _interactiveDismiss = [[AKTInteractiveDismiss alloc]initWithViewController:self]; 124 | } 125 | return _interactiveDismiss; 126 | } 127 | 128 | - (AKTNavigationBar *)naviBar { 129 | if (_naviBar == nil) { 130 | _naviBar = [AKTNavigationBar new]; 131 | [self.view addSubview:_naviBar]; 132 | } 133 | return _naviBar; 134 | } 135 | #pragma mark - delegate 136 | //|--------------------------------------------------------- 137 | - (nullable id )animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { 138 | return self.pAnimation; 139 | } 140 | 141 | - (nullable id )animationControllerForDismissedController:(UIViewController *)dismissed { 142 | return self.dAnimation; 143 | } 144 | 145 | - (nullable id )interactionControllerForDismissal:(id )animator { 146 | return self.interactiveDismiss.isInteracting? self.interactiveDismiss:nil; 147 | } 148 | @end 149 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTKit.h 3 | // AKTLayoutDemo 4 | // 5 | // Created by YaHaoo on 16/1/18. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #ifndef AKTKit_h 10 | #define AKTKit_h 11 | #import "AKTPublic.h" 12 | #import "UIView+AKTLayout.h" 13 | #import "AKTCategory.h" 14 | #import "AKTUI.h" 15 | #endif /* AKTKit_h */ 16 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/AKTAttributeItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTAttributeItem.h 3 | // AKTLayout 4 | // 5 | // Created by YaHaoo on 16/4/15. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | // import- 10 | #import 11 | // import-"models.h" 12 | #import "AKTReferenceConfiguration.h" 13 | // import-"views & controllers.h" 14 | 15 | //--------------# Macro #-------------- 16 | #define kTypeMaximum (8) 17 | //--------------# E.n.d #--------------#>Macro 18 | 19 | //--------------------Structs statement, globle variables...-------------------- 20 | // The definition of "AKTAttributeItem" 21 | // 布局项定义 22 | struct AKTAttributeItemStruct{ 23 | AKTAttributeItemType typeArray[kTypeMaximum]; 24 | int typeCount; 25 | AKTReferenceConfiguration configuration; 26 | const void *bindView; 27 | } ; 28 | typedef struct AKTAttributeItemStruct AKTAttributeItem; 29 | typedef AKTAttributeItem* AKTAttributeItemRef; 30 | 31 | // View attribute 32 | @interface AKTViewAttribute : NSObject 33 | @property (weak, nonatomic) UIView *referenceView; 34 | @property (assign, nonatomic) AKTAttributeItemType type; 35 | @end 36 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 37 | 38 | #pragma mark - life cycle 39 | //|--------------------------------------------------------- 40 | /** 41 | * Initialize layout attribute item. 42 | * 布局项初始化 43 | * 44 | * @param itemRef Layout attribute item need to be initalized. 45 | * @param itemRef 需要被初始化的布局项 46 | */ 47 | void aktAttributeItemInit(AKTAttributeItemRef itemRef); 48 | 49 | #pragma mark - add layout item type methods 50 | //|--------------------------------------------------------- 51 | /** 52 | * Add layout attribute item type. 53 | * 添加布局项类型. 54 | * 55 | */ 56 | void __andTop_imp__(); 57 | void __andLeft_imp__(); 58 | void __andBottom_imp__(); 59 | void __andRight_imp__(); 60 | void __andWidth_imp__(); 61 | void __andHeight_imp__(); 62 | void __andWHRatio_imp__(); 63 | void __andCenterX_imp__(); 64 | void __andCenterY_imp__(); 65 | void __andCenterXY_imp__(); 66 | 67 | /** 68 | * Establish references 69 | * 建立参照 70 | * 71 | * @param reference Reference layout object:(view,coordinate,size) 72 | * @param reference 布局所参考的对象:(视图,坐标,大小) 73 | * 74 | * @return Reference configuration object. 75 | * @return 参考设置对象 76 | */ 77 | void __equalTo_imp__(AKTReference reference); 78 | #pragma mark - function implementations 79 | //|--------------------------------------------------------- 80 | /** 81 | * Get reference value from view attribute. 82 | * 从veiwAttribute获取参考值 83 | * 84 | * @param attribute View attributes 85 | * @param attribute 视图属性 86 | * @param bindView Bind view 87 | * @param bindView 绑定视图 88 | * 89 | * @return Reference value 90 | * @return 参考值 91 | */ 92 | CGFloat getValue(AKTViewAttributeInfo attributeInfo, UIView *bindView); 93 | 94 | /* 95 | * Return origin*multiple+offset 96 | */ 97 | CGFloat calculate(CGFloat origin, CGFloat multiple, CGFloat coefficientOffset, CGFloat offset); -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/AKTLayout.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/AKTKit/ARC_File/AKTLayout/AKTLayout.xmind -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/AKTLayoutAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTLayoutAttribute.h 3 | // AKTLayout 4 | // 5 | // Created by YaHaoo on 16/4/15. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | // import- 10 | #import 11 | #import 12 | // import-"models.h" 13 | #import "AKTAttributeItem.h" 14 | // import-"views & controllers.h" 15 | 16 | //--------------# Macro #-------------- 17 | #define kItemMaximum (10) 18 | //--------------# E.n.d #--------------#>Macro 19 | 20 | //--------------------Structs statement, globle variables...-------------------- 21 | typedef struct { 22 | const void *conditionBlock; 23 | const void *attributeBlock; 24 | } AKTDynamicLayoutBlock; 25 | 26 | typedef struct { 27 | //> 不可变布局信息 28 | AKTAttributeItem itemArrayForStatic[kItemMaximum]; 29 | int itemCountForStatic; 30 | //> Layout info, array elements are layout items. 可变布局信息,数组元素是布局项(在满足某种条件时会被重新赋值) 31 | AKTAttributeItem itemArrayForDynamic[kItemMaximum]; 32 | int itemCountForDynamic; 33 | 34 | //> 需要被布局的view 35 | //> 是否已经检查 36 | //> 更新布局信息时生成的tag,用以区分不同的布局信息 37 | //> 是否正在获取动态布局信息, 信息将被存储到动态部分 38 | //> 有效的布局信息,当某个参照视图销毁时,布局信息将无效 39 | const void *bindView; 40 | bool currentLayoutInfoDidCheck; 41 | long layoutInfoTag; 42 | bool layoutDynamicContextBegin; 43 | bool validLayoutAttributeInfo; 44 | 45 | AKTDynamicLayoutBlock blockArrayForDynamic[kItemMaximum]; 46 | int blockCountForDynamic; 47 | 48 | // 当前参照视图的集合 49 | void *currentViewReferenced[kItemMaximum*2]; 50 | int viewReferenced; 51 | } AKTLayoutAttribute; 52 | typedef AKTLayoutAttribute* AKTLayoutAttributeRef; 53 | // Shared attributeRef 54 | extern AKTLayoutAttributeRef attributeRef_global; 55 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 56 | #pragma mark - life cycle 57 | //|--------------------------------------------------------- 58 | /** 59 | * Initialize AKTLayoutAttribute. 60 | * 初始化 61 | * 62 | * @param attributeRef "AKTLayoutAttribute" need to be initialized. 63 | * @param attributeRef 需要被初始化的"AKTLayoutAttribute" 64 | * @param view The view need to be layout 65 | * @param view 需要被布局的视图 66 | */ 67 | void aktLayoutAttributeInit(UIView *view); 68 | 69 | /** 70 | * AKTLayoutAttribute deallock 71 | * 72 | * @param attributeRef 73 | */ 74 | void aktLayoutAttributeDealloc(AKTLayoutAttributeRef attributeRef, bool freeMemory); 75 | #pragma mark - create item 76 | //|--------------------------------------------------------- 77 | /** 78 | * Create layout attribute item. 79 | * 创建布局项. 80 | * 81 | */ 82 | void __akt__create__top(); 83 | void __akt__create__left(); 84 | void __akt__create__bottom(); 85 | void __akt__create__right(); 86 | void __akt__create__width(); 87 | void __akt__create__height(); 88 | void __akt__create__whRatio(); 89 | void __akt__create__centerX(); 90 | void __akt__create__centerY(); 91 | void __akt__create__centerXY(); 92 | void __akt__create__edge(); 93 | void __akt__create__size(); 94 | 95 | #pragma mark - function implementations 96 | //|--------------------------------------------------------- 97 | /* 98 | * Calculate layout with the infor from the attribute items, return CGRect 99 | * Configurations in AKTLayoutParam, as follows configurations can be divided into vertical and horizontal direction 100 | * In one direction two configurations in addition to "whRatio" is enough to calculate the frame in that direction. WhRation will be convert to the configuration of width or height 101 | */ 102 | CGRect calculateAttribute(AKTLayoutAttributeRef attributeRef, const void *referenceViewPtr); 103 | 104 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/AKTLayoutShell.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTLayoutShellAttribute.h 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/19. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | // import- 11 | // import-"models.h" 12 | #import "UIView+ViewAttribute.h" 13 | #import "AKTLayoutAttribute.h" 14 | // import-"views & controllers.h" 15 | 16 | @interface AKTLayoutShellConfigure : NSObject 17 | /* 18 | * Multiple and offset 19 | */ 20 | - (AKTLayoutShellConfigure *(^)(CGFloat obj))multiple; 21 | - (AKTLayoutShellConfigure *(^)(CGFloat obj))offset; 22 | - (AKTLayoutShellConfigure *(^)(CGFloat obj))coefficientOffset; 23 | - (AKTLayoutShellConfigure *(^)(UIEdgeInsets inset))edgeInset; 24 | @end 25 | 26 | @interface AKTLayoutShellItem : NSObject 27 | // Configure layout attribute item 28 | - (AKTLayoutShellItem *)top; 29 | - (AKTLayoutShellItem *)left; 30 | - (AKTLayoutShellItem *)bottom; 31 | - (AKTLayoutShellItem *)right; 32 | - (AKTLayoutShellItem *)width; 33 | - (AKTLayoutShellItem *)height; 34 | - (AKTLayoutShellItem *)whRatio; 35 | - (AKTLayoutShellItem *)centerX; 36 | - (AKTLayoutShellItem *)centerY; 37 | - (AKTLayoutShellItem *)centerXY; 38 | 39 | // End set layout attribute item and set reference object 40 | - (AKTLayoutShellConfigure *(^)(AKTReference reference))equalTo; 41 | @end 42 | 43 | @interface AKTLayoutShellAttribute : NSObject 44 | AKTLayoutShellAttribute *sharedShellAttribute(); 45 | /* 46 | * Create layout attribute item 47 | */ 48 | - (AKTLayoutShellItem *)top; 49 | - (AKTLayoutShellItem *)left; 50 | - (AKTLayoutShellItem *)bottom; 51 | - (AKTLayoutShellItem *)right; 52 | - (AKTLayoutShellItem *)width; 53 | - (AKTLayoutShellItem *)height; 54 | - (AKTLayoutShellItem *)whRatio; 55 | - (AKTLayoutShellItem *)centerX; 56 | - (AKTLayoutShellItem *)centerY; 57 | - (AKTLayoutShellItem *)centerXY; 58 | - (AKTLayoutShellItem *)edge; 59 | - (AKTLayoutShellItem *)size; 60 | 61 | /** 62 | * Add dynamic layout for view. Layout info will be update when needed. 63 | * @note: When the condition returned YES, attribute will be update to the view's layout info storage. 64 | * 65 | * @param condition Condition for updating layout info. 66 | * @param attribute Block for updateing layout info. 67 | */ 68 | - (void)addDynamicLayoutInCondition:(BOOL(^)())condition andAttribute:(void(^)(AKTLayoutShellAttribute *dynamicLayout))attribute; 69 | @end 70 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/AKTReferenceConfiguration.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKTReferenceObject.h 3 | // AKTLayout 4 | // 5 | // Created by YaHaoo on 16/4/15. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | // import- 11 | #import 12 | // import-"models.h" 13 | 14 | // import-"views & controllers.h" 15 | 16 | //--------------# Macro #-------------- 17 | #define akt_value(VALUE) (__akt_value(VALUE)) 18 | #define akt_view(VIEW) (__akt_view(VIEW)) 19 | #define akt_size(WIDTH, HEIGHT) (__akt_size(WIDTH, HEIGHT)) 20 | #define akt_inset(TOP, LEFT, BOTTOM, RIGHT) (__akt_inset(TOP, LEFT, BOTTOM, RIGHT)) 21 | //--------------# E.n.d #--------------#>Macro 22 | 23 | //--------------------Structs statement, globle variables...-------------------- 24 | // AKTAttributeItemType 25 | // 布局项类型 26 | typedef enum { 27 | AKTAttributeItemType_Top, 28 | AKTAttributeItemType_Left, 29 | AKTAttributeItemType_Bottom, 30 | AKTAttributeItemType_Right, 31 | AKTAttributeItemType_Width, 32 | AKTAttributeItemType_Height, 33 | AKTAttributeItemType_WHRatio, 34 | AKTAttributeItemType_CenterX, 35 | AKTAttributeItemType_CenterY, 36 | AKTAttributeItemType_CenterXY 37 | } AKTAttributeItemType; 38 | 39 | // Layout reference type 40 | // 布局参考类型 41 | typedef enum { 42 | AKTRefenceType_View, 43 | AKTRefenceType_ViewAttribute, 44 | AKTRefenceType_Constant 45 | } AKTRefenceType; 46 | 47 | typedef struct { 48 | void *referenceView; 49 | AKTAttributeItemType type; 50 | }AKTViewAttributeInfo; 51 | 52 | typedef struct { 53 | bool referenceValidate; 54 | AKTRefenceType referenceType; 55 | AKTViewAttributeInfo referenceAttribute; 56 | void *referenceView; 57 | CGFloat referenceValue; 58 | CGSize referenceSize; 59 | } AKTReference; 60 | typedef AKTReference* AKTRefenceRef; 61 | 62 | /* 63 | * AKTLayoutReferenceObjInfo 64 | */ 65 | struct AKTReferenceConfigurationStruct { 66 | AKTReference reference; 67 | UIEdgeInsets referenceEdgeInsert; 68 | float referenceMultiple; 69 | float referenceCoefficientOffset; 70 | float referenceOffset; 71 | }; 72 | typedef struct AKTReferenceConfigurationStruct AKTReferenceConfiguration; 73 | typedef AKTReferenceConfiguration* AKTReferenceConfigurationRef; 74 | 75 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 76 | #pragma mark - life cycle 77 | //|--------------------------------------------------------- 78 | /** 79 | * Initialize reference configuration. 80 | * 初始化参考设置. 81 | * 82 | * @param configureRef Reference configuration need to be initalized. 83 | * @param configureRef 需要被初始化的参考设置 84 | */ 85 | void aktReferenceConfigurationInit(AKTReferenceConfigurationRef configureRef); 86 | 87 | /** 88 | * Initialize reference. 89 | * 参考信息初始化 90 | * 91 | * @param referenceRef Reference need to be initalized. 92 | * @param referenceRef 需要被初始化的参考 93 | */ 94 | void aktReferenceInit(AKTRefenceRef referenceRef); 95 | #pragma mark - reference methods 96 | //|--------------------------------------------------------- 97 | // Create reference object. 98 | // 创建参考 99 | AKTReference __akt_size(float width, float height); 100 | 101 | AKTReference __akt_value(float value); 102 | 103 | AKTReference __akt_view(UIView *view); 104 | 105 | UIEdgeInsets __akt_inset(float top, float left, float bottom, float right); 106 | #pragma mark - configuration methods 107 | //|--------------------------------------------------------- 108 | /** 109 | * Transformation of the result. 110 | * 对于结果的变换 111 | * 112 | * @param value multiple 113 | * @param value 倍数 114 | * 115 | */ 116 | void __akt__add__multiple(CGFloat value); 117 | 118 | /** 119 | * Transformation of the result. 120 | * 对于结果的变换 121 | * 122 | * @param value Offset 123 | * @param value 偏移值 124 | * 125 | * @note The final result = reference object * multiple + offset. 126 | * @note 最终的结果=参考对象*倍数+偏移值 127 | */ 128 | void __akt__add__offset(CGFloat value); 129 | 130 | /** 131 | * Transformation of the result. 132 | * 对于结果的变换 133 | * 134 | * @param value coefficientOffset 135 | * @param value 系数偏移值 136 | * 137 | * @note The final result = (reference object + coefficientOffset)* multiple + offset. 138 | * @note 最终的结果=(参考对象+系数偏移值)*倍数+偏移值 139 | */ 140 | void __akt__add__coefficientOffset(CGFloat value); 141 | 142 | /** 143 | * The value of edge inset. 144 | * 边缘插入值 145 | * 146 | * @param inset Edge inset value 147 | * @param inset 插入值 148 | * 149 | * @note Only work when you add the attribute item type "edge" into the layout attribute item. And if this layout attribuite item also add other attribute item types, the other item types will not work. 150 | * @note 仅仅对添加了"edge"类型的布局项起作用。同时如果此布局项还添加了其它的布局类型,则其它的布局类型将不起作用。 151 | */ 152 | void __akt__add__edgeInset(UIEdgeInsets inset); 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTLayout/UIView+AKTLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+QuickLayout.h 3 | // AKTeamUikitExtension 4 | // 5 | // Our goal is to be the best framework for automatic layout 6 | // Your support will help AKTLayout rising, welcome to provide code support, suggest improvements to AKTLayout or lit a Star for us 7 | // https://github.com/AkteamYang/AKTKit.AKTLayout 8 | // AKTLayout version 1.2.0 9 | // 10 | // Created by YaHaoo on 15/9/8. 11 | // Copyright (c) 2015年 CoolHear. All rights reserved. 12 | // 13 | 14 | #import 15 | // import- 16 | // import-"models.h" 17 | #import "AKTLayoutAttribute.h" 18 | #import "AKTLayoutShell.h" 19 | // import-"views & controllers.h" 20 | 21 | //--------------# Macro #-------------- 22 | 23 | //--------------# E.n.d #--------------#>Macro 24 | 25 | //--------------------Structs statement, globle variables...-------------------- 26 | // 快速布局约束类型 27 | typedef NS_ENUM(NSInteger, QuickLayoutConstraintType) { 28 | QuickLayoutConstraintAlignTo_Top, 29 | QuickLayoutConstraintAlignTo_Left, 30 | QuickLayoutConstraintAlignTo_Bottom, 31 | QuickLayoutConstraintAlignTo_Right, 32 | 33 | QuickLayoutConstraintSpaceTo_Top, 34 | QuickLayoutConstraintSpaceTo_Left, 35 | QuickLayoutConstraintSpaceTo_Bottom, 36 | QuickLayoutConstraintSpaceTo_Right, 37 | 38 | QuickLayoutConstraintAlign_Vertical, 39 | QuickLayoutConstraintAlign_Horizontal, 40 | 41 | QuickLayoutConstraintWidth, 42 | QuickLayoutConstraintHeight, 43 | QuickLayoutConstraintRateW_H 44 | }; 45 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 46 | 47 | /* 48 | * AktLayout 49 | */ 50 | @interface UIView (AKTLayout) 51 | //> Frame设置相关的属性 52 | @property (nonatomic) CGFloat x; 53 | @property (nonatomic) CGFloat y; 54 | @property (nonatomic) CGFloat width; 55 | @property (nonatomic) CGFloat height; 56 | //> AKTLayout Debug日志将用此名称进行打印日志 57 | @property (copy, nonatomic) NSString *aktName; 58 | 59 | - (AKTReference)akt_top; 60 | - (AKTReference)akt_left; 61 | - (AKTReference)akt_bottom; 62 | - (AKTReference)akt_right; 63 | - (AKTReference)akt_width; 64 | - (AKTReference)akt_height; 65 | - (AKTReference)akt_whRatio; 66 | - (AKTReference)akt_centerX; 67 | - (AKTReference)akt_centerY; 68 | 69 | #pragma mark - QuickLayout 70 | //|--------------------------------------------------------- 71 | /** 72 | * 快速布局 73 | * 74 | * @param type 快速布局约束类型 75 | * @param referenceView 参考视图 76 | * @param offset 偏移值 77 | */ 78 | - (void)AKTQuickLayoutWithType:(QuickLayoutConstraintType)type referenceView:(UIView *)referenceView offset:(CGFloat)offset; 79 | 80 | #pragma mark - AKTLayout 81 | //|--------------------------------------------------------- 82 | /* 83 | * Configure layout attributes. It's a AKTLayout method and you can add layout items such as: top/left/bottom/width/whRatio... into currentView. When you add items you don't need to care about the order of these items. The syntax is very easy to write and understand. In order to meet the requirements, we did a lot in the internal processing. But the performance is still outstanding. I have already no longer use autolayout. Because autolayout has a bad performance especially when the view is complex.In order to guarantee the performance we can handwrite frame code. But it's a boring thing and a waste of time. What should I do? Please try AKTLayout!!! 84 | * 添加AKTLayout布局属性,你可以为视图添加多种布局项(top/left/bottom/width/whRatio...),当你添加布局项时你不用关心添加的顺序,语法非常容易理解和编写,为了达到要求我们进行了很多内部转换,但是仍然保持了高性能表现,我已经很久不用系统的自动布局,因为在复杂的视图关系中,它的性能表现实在过于糟糕,为了达到性能要求,必须要手写并计算布局代码,这是一件令人乏味而耗费时间的事情,如果你正在被这些问题困扰,可以尝试一下性能优异的AKTLayout!!! 85 | * https://github.com/AkteamYang/AKTKit.AKTLayout 86 | * 我们的目标是成为最好的自动布局框架 87 | * 你的支持将有助于AKTLayout不断提升,欢迎为AKTLayout提供代码支持、改进建议或者为我们点上一颗Star 88 | */ 89 | - (void)aktLayout:(void(^)(AKTLayoutShellAttribute *layout))layout; 90 | 91 | /** 92 | * 设置视图需要刷新布局 93 | * @备注:一般在更改了view的size需要立刻执行布局刷新时调用 94 | */ 95 | - (void)setNeedAKTLayout; 96 | 97 | /** 98 | * 已经完成布局 99 | * @备注:当视图布局完成时会回调这个方法 100 | * 101 | * @param target 102 | * @param selector selector的参数是当前的view (- (void)viewDidLayout:(UIView *)view) 103 | */ 104 | - (void)aktDidLayoutTarget:(id)target forSelector:(SEL)selector; 105 | 106 | /** 107 | * 已经完成布局 108 | * 109 | * @param complete 110 | */ 111 | - (void)aktDidLayoutWithComplete:(void(^)(UIView *view))complete; 112 | 113 | /* 114 | * 当view的size变化时将被自动调用 115 | * 在1.0以上版本中已被废弃,不建议再使用,如果要使用请重写"layoutSubviews"方法。 116 | */ 117 | - (void)aktLayoutUpdate DEPRECATED_MSG_ATTRIBUTE("Last version 1.0"); 118 | 119 | /** 120 | * 添加AKTLyout动画 121 | * 122 | * @param animation 动画代码 123 | */ 124 | + (void)aktAnimation:(void(^)())animation; 125 | 126 | /** 127 | * 是否支持旋转屏幕动画 128 | * @备注:当支持旋转屏幕动画时,旋转屏幕视图布局速度将降低!一般情况下默认开启 129 | * 130 | * @param support 131 | */ 132 | + (void)aktScreenRotatingAnimationSupport:(BOOL)support; 133 | #pragma mark - distribute 134 | //|--------------------------------------------------------- 135 | /* 136 | * 将给定的view分布放置 137 | * @source:view 数组 138 | * @rect:最终分布的矩形区域, 139 | * @lines: 行数 140 | * @columns: 列数 141 | * @itemHandler: 每放置好一个view,将会调用一次block 142 | * @note:view放置在行和列的交叉点 143 | */ 144 | - (void)aktLayoutDistributeSource:(NSArray *)source distributeRect:(CGRect)rect lines:(NSInteger)lines columns:(NSInteger)columns itemHandler:(void(^)(UIView *item))itemHandler; 145 | @end 146 | -------------------------------------------------------------------------------- /AKTKit/ARC_File/AKTPublic.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKTPublic.c 3 | // Pursue 4 | // 5 | // Created by YaHaoo on 16/3/19. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #include "AKTPublic.h" 10 | /* 11 | * Safty check whether "a" is equal to "b". Support: int float or double 12 | */ 13 | bool aktValueEqual(double a, double b) { 14 | double delta = ABS(a-b); 15 | if (delta>1) { 16 | return false; 17 | }else{ 18 | delta *= 1e4; 19 | if (delta>1) { 20 | return false; 21 | }else{ 22 | return true; 23 | } 24 | } 25 | } 26 | 27 | UIImage * aktNoBlendImage(UIImage *image, UIColor *backgroundColor) { 28 | UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale); 29 | [backgroundColor setFill]; 30 | CGRect rec = CGRectMake(0, 0, image.size.width, image.size.height); 31 | CGContextRef context = UIGraphicsGetCurrentContext(); 32 | CGContextFillRect(context, rec); 33 | [image drawInRect:rec]; 34 | UIImage *imageNew = UIGraphicsGetImageFromCurrentImageContext(); 35 | UIGraphicsEndImageContext(); 36 | return imageNew; 37 | } 38 | 39 | /* 40 | * Random color 41 | */ 42 | UIColor *aktRandomColor(CGFloat alpha) { 43 | int r, g, b; 44 | while (1) { 45 | r = arc4random()%255; 46 | g = arc4random()%255; 47 | b = arc4random()%255; 48 | if (ABS(g-r)+ABS(b-r)>40) { 49 | break; 50 | } 51 | } 52 | return [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:alpha]; 53 | } 54 | 55 | /** 56 | * Round corner 57 | * 58 | * @param view 59 | * @param cornerRadius 60 | */ 61 | void addmask(UIView *view, CGFloat cornerRadius) { 62 | CAShapeLayer *maskLayer = AKTAutorelease([[CAShapeLayer alloc]init]); 63 | maskLayer.frame = view.bounds; 64 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.bounds cornerRadius:cornerRadius]; 65 | maskLayer.path = [path CGPath]; 66 | view.layer.mask = maskLayer; 67 | } 68 | 69 | /** 70 | * 获取像素级尺寸 71 | * 72 | * @param value 73 | * 74 | * @return 75 | */ 76 | CGFloat aktPicFloat(CGFloat value) { 77 | static CGFloat unit; 78 | static dispatch_once_t onceToken; 79 | dispatch_once(&onceToken, ^{ 80 | unit = 1/[UIScreen mainScreen].scale; 81 | }); 82 | CGFloat decimalValue = value - (NSInteger)value; 83 | value = (NSInteger)value+unit*(NSInteger)(decimalValue/unit+1); 84 | return value; 85 | } 86 | 87 | CGRect aktPixRect(CGFloat x, CGFloat y, CGFloat width, CGFloat height) { 88 | return CGRectMake(aktPicFloat(x), aktPicFloat(y), aktPicFloat(width), aktPicFloat(height)); 89 | } 90 | 91 | CGSize aktPixSize(CGFloat width, CGFloat height) { 92 | return CGSizeMake(aktPicFloat(width), aktPicFloat(height)); 93 | } -------------------------------------------------------------------------------- /AKTKit/MRC_File/UIView+ViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+ViewAttribute.h 3 | // AKTLayout 4 | // 5 | // Created by YaHaoo on 16/4/16. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | @class AKTWeakContainer; 11 | 12 | /** 13 | * AKTLayout的布局更新处理模块MRC编译选项 14 | */ 15 | @interface UIView (ViewAttribute) 16 | //> 自适应高度和宽度,默认值为nil,不做任何自适应处理 17 | @property (strong, nonatomic) NSNumber *adaptiveWidth; 18 | @property (strong, nonatomic) NSNumber *adaptiveHeight; 19 | //> 布局信息 20 | @property (assign, nonatomic) void *attributeRef; 21 | //> 布局链, 包含了参考了当前视图的布局,当当前视图布局改变时将刷新链表中的视图的布局 22 | @property (readonly, strong, nonatomic) NSMutableSet *layoutChain; 23 | //> 当前视图所参考的视图的数组 24 | @property (readonly, strong, nonatomic) NSMutableSet *viewsReferenced; 25 | //> 布局需要被刷新次数 26 | @property (assign, nonatomic) NSInteger layoutUpdateCount; 27 | //> 弱引用容器 28 | @property (retain, nonatomic) AKTWeakContainer *aktContainer; 29 | 30 | /** 31 | * AKTLayout standard log 32 | * 33 | * @param errorCode 34 | * @param description 35 | * @param suggest 36 | */ 37 | void __aktErrorReporter(int errorCode, NSString *description, NSString *suggest); 38 | 39 | /** 40 | * 已经布局完成回调 41 | * 42 | * @param view 当前视图 43 | */ 44 | void __aktViewDidLayoutWithView(UIView *view); 45 | @end 46 | 47 | @interface AKTWeakContainer : NSObject 48 | @property (assign, nonatomic) UIView *weakView; 49 | @end 50 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcodeproj/xcuserdata/HaoYang.xcuserdatad/xcschemes/AKTLayoutExmaple.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcodeproj/xcuserdata/HaoYang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AKTLayoutExmaple.xcscheme 8 | 9 | orderHint 10 | 3 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F8BDB75F1CF1936000E31155 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcodeproj/xcuserdata/YaHaoo.xcuserdatad/xcschemes/AKTLayoutExmaple.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcodeproj/xcuserdata/YaHaoo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AKTLayoutExmaple.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F8BDB75F1CF1936000E31155 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcworkspace/xcuserdata/HaoYang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple.xcworkspace/xcuserdata/YaHaoo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | #import "AKTKit.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // ViewController *vc = [ViewController new]; 22 | // UIView *vv = vc.view; 23 | // UINavigationController *nv = [[UINavigationController alloc]initWithRootViewController:vc]; 24 | // self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; 25 | // self.window.rootViewController = nv; 26 | // [self.window makeKeyAndVisible]; 27 | // Override point for customization after application launch. 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 34 | } 35 | 36 | - (void)applicationDidEnterBackground:(UIApplication *)application { 37 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 39 | } 40 | 41 | - (void)applicationWillEnterForeground:(UIApplication *)application { 42 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 43 | } 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application { 46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 47 | } 48 | 49 | - (void)applicationWillTerminate:(UIApplication *)application { 50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AKTLogo.imageset/AKTLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AKTLogo.imageset/AKTLogo.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AKTLogo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "AKTLogo.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "size" : "60x60", 25 | "idiom" : "iphone", 26 | "filename" : "icon@2x.png", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "size" : "60x60", 31 | "idiom" : "iphone", 32 | "filename" : "icon@3x.png", 33 | "scale" : "3x" 34 | } 35 | ], 36 | "info" : { 37 | "version" : 1, 38 | "author" : "xcode" 39 | } 40 | } -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AppIcon.appiconset/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AppIcon.appiconset/icon@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AppIcon.appiconset/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/AppIcon.appiconset/icon@3x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExampleAKTLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleAKTLayout.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExampleAKTLayout : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExampleAKTLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleAKTLayout.m 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "ExampleAKTLayout.h" 10 | #import "AKTKit.h" 11 | 12 | //--------------------Structs statement, globle variables...-------------------- 13 | extern const int kColumns; 14 | extern const int kLines; 15 | //-------------------- E.n.d -------------------->Structs statement, globle variables... 16 | 17 | @interface ExampleAKTLayout () 18 | 19 | @end 20 | 21 | @implementation ExampleAKTLayout 22 | #pragma mark - life cycle 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | [self initUI]; 26 | // Do any additional setup after loading the view. 27 | } 28 | 29 | - (void)didReceiveMemoryWarning { 30 | [super didReceiveMemoryWarning]; 31 | // Dispose of any resources that can be recreated. 32 | } 33 | 34 | #pragma mark - view settings 35 | - (void)initUI { 36 | self.view.backgroundColor = [UIColor whiteColor]; 37 | // 设置导航 38 | self.view.aktName = @"self.view"; 39 | [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc]initWithImage:mAKT_Image_Origin(@"P_Back") style:(UIBarButtonItemStylePlain) target:self action:@selector(back)]]; 40 | [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc]initWithImage:mAKT_Image_Origin(@"P_Rotate") style:(UIBarButtonItemStylePlain) target:self action:@selector(rotate)]]; 41 | // 加载AKTLayout 42 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 43 | [self initUIAkt]; 44 | }); 45 | } 46 | 47 | - (void)initUIAkt { 48 | double a, b; 49 | a = [[NSDate new] timeIntervalSince1970]; 50 | NSLog(@"%lf",a-a); 51 | int lines = kLines, columns = kColumns; 52 | UIView *last; 53 | for (int i = 0; i 10 | 11 | @interface ExampleAnima : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExampleCoverView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCoverView.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by HaoYang on 16/6/24. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExampleCoverView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExampleCoverView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCoverView.m 3 | // AKTLayoutExmaple 4 | // 5 | // Created by HaoYang on 16/6/24. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "ExampleCoverView.h" 10 | // import- 11 | #import "AKTKit.h" 12 | // Function Module 13 | 14 | // import-"models.h" 15 | 16 | // import-"views..." 17 | 18 | // import-"aid.h" 19 | 20 | //--------------# Macro & Const #-------------- 21 | #define kExampleTint1 mAKT_Color_Color(80, 128, 215, .5) 22 | //--------------# E.n.d #--------------#>Macro 23 | 24 | @interface ExampleCoverView() 25 | @property (strong, nonatomic) UIImageView *coverImg; 26 | @end 27 | @implementation ExampleCoverView 28 | #pragma mark - property settings 29 | - (UIImageView *)coverImg { 30 | if (!_coverImg) { 31 | _coverImg = [UIImageView new]; 32 | [self addSubview:_coverImg]; 33 | _coverImg.image = mAKT_Image(@"over.jpg"); 34 | _coverImg.layer.masksToBounds = YES; 35 | [_coverImg aktLayout:^(AKTLayoutShellAttribute *layout) { 36 | layout.edge.equalTo(akt_view(self)); 37 | }]; 38 | } 39 | return _coverImg; 40 | } 41 | 42 | #pragma mark - life cycle 43 | - (instancetype)init 44 | { 45 | self = [super init]; 46 | if (self) { 47 | [self initUI]; 48 | } 49 | return self; 50 | } 51 | 52 | #pragma mark - view settings 53 | - (void)initUI { 54 | self.layer.masksToBounds = YES; 55 | self.backgroundColor = kExampleTint1; 56 | _coverImg = self.coverImg; 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExampleMasonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleMasonry.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExampleMasonry : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExamplePlayer+UIControls.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExamplePlayer+UIControls.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/6/21. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "ExamplePlayer.h" 10 | #import "ExamplePlayerPrivate.h" 11 | 12 | @interface ExamplePlayer (UIControls) 13 | - (void)initUIForContainer; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExamplePlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExamplePlayer.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/25. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExamplePlayer : UIViewController 12 | 13 | @end -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ExamplePlayerPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExamplePlayerPrivate.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by HaoYang on 16/6/21. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ExampleCoverView.h" 11 | 12 | @protocol ExamplePlayerPrivate 13 | @optional 14 | @property (strong, nonatomic) UILabel *drag; 15 | @property (strong, nonatomic) UIView *container; 16 | 17 | // Player UI controls 18 | @property (strong, nonatomic) UIImageView *coverLittle; 19 | @property (strong, nonatomic) UILabel *musicName; 20 | @property (strong, nonatomic) UILabel *artist; 21 | //> Player music control 22 | @property (strong, nonatomic) UIButton *play; 23 | @property (strong, nonatomic) UIButton *nextMusic; 24 | @property (strong, nonatomic) UIButton *lastMusic; 25 | @property (strong, nonatomic) UIButton *list; 26 | @property (strong, nonatomic) UIButton *mode; 27 | //> Player progress control 28 | @property (strong, nonatomic) UISlider *slider; 29 | @property (strong, nonatomic) UILabel *currentTime; 30 | @property (strong, nonatomic) UILabel *duration; 31 | //> Big cover 32 | @property (strong, nonatomic) ExampleCoverView *cover; 33 | //> Music and artist label on the top 34 | @property (strong, nonatomic) UILabel *topMusicName; 35 | @property (strong, nonatomic) UILabel *topArtist; 36 | @end 37 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Anima@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Anima@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Example@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Example@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Header@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Header@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Test1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Test1@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Test2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/AKT_Test2@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Last@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Last@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_ListBig@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_ListBig@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_ListLittle@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_ListLittle@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Mode0@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Mode0@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Mode1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Mode1@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Next@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_Next@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PauseBig@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PauseBig@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PauseLittle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PauseLittle.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PlayBig@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PlayBig@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PlayLittle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/CH_PlayLittle.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/Cover@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/Cover@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Back@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Navi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Navi.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Rotate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Rotate@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Stop@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/P_Stop@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/over.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/over.jpg -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/slider@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Images/slider@2x.png -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarStyle 34 | UIStatusBarStyleLightContent 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | UIInterfaceOrientationPortraitUpsideDown 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | UIViewControllerBasedStatusBarAppearance 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/NavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by HaoYang on 16/6/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/NavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.m 3 | // AKTLayoutExmaple 4 | // 5 | // Created by HaoYang on 16/6/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "NavigationController.h" 10 | 11 | @implementation NavigationController 12 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations { 13 | if ([self.topViewController isKindOfClass:NSClassFromString(@"ExamplePlayer")]) { 14 | return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 15 | } 16 | return UIInterfaceOrientationMaskPortrait | 17 | UIInterfaceOrientationMaskPortraitUpsideDown | 18 | UIInterfaceOrientationMaskLandscapeLeft | 19 | UIInterfaceOrientationMaskLandscapeRight; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/AKTLayoutExmaple/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AKTLayoutExmaple 4 | // 5 | // Created by YaHaoo on 16/5/22. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.1' 2 | target 'AKTLayoutExmaple' do 3 | pod 'AKTLayout' 4 | pod 'Masonry', '~> 1.0.0' 5 | end 6 | -------------------------------------------------------------------------------- /Exmaples/AKTLayoutExmaple/README.md: -------------------------------------------------------------------------------- 1 | [ ![AKTKit.AKTLayout](https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/master/Imgs/AKTLayout.jpg) ](https://github.com/AkteamYang/AKTKit.AKTLayout) 2 | # [AKTLayout](https://github.com/AkteamYang/AKTKit.AKTLayout) 3 | https://github.com/AkteamYang/AKTKit.AKTLayout 4 | 5 | AKTLayout是一个服务于IOS平台的高性能自动布局框架。由于系统的自动布局在复杂的界面呈现中,性能衰减十分严重(Masonry、PureLayout、FLKAutoLayout...都是基于`NSLayoutConstraint`的自动布局书写框架)。AKTLayout最初的目的仅仅是为了简化手动布局时的代码编写,后来引入了高性能的内建自动布局引擎,展现出令人惊喜的特性 6 | 7 | ![AKTKit.AKTLayout](https://github.com/AkteamYang/AKTKit.AKTLayout/blob/master/Imgs/Demo/Demo1.gif?raw=true) 8 | > 动态特性 9 | 10 | #### 参照类型 11 | 12 | | vertical | horizontal | 13 | | :------------: | :------------: | 14 | | top | left | 15 | | bottom | right | 16 | | height | width | 17 | | centerY | centerX | 18 | 19 | 参照分为垂直和水平方向,在不设置长宽比例的情况下,每个方向只要有两个参照就足够足够确定view的大小和位置。size、whRatio和edge较为特殊,直接参照size、宽高比和edge,过多的参照将会被舍弃,不同的参照关系最终将转化到坐标关系,下面我将详细描述参照。 20 | 21 | ![AKTKit.AKTLayout](https://github.com/AkteamYang/AKTKit.AKTLayout/blob/master/Imgs/Demo/reference.png?raw=true) 22 | > 参照最终体现到坐标值,除了的`size`和`edge`之外,其余的参照都可以参考固定值和视图,为了提高运算效率参照的写法做了特殊规定,只能通过框架提供的固定方法获取:`aktValue()`、`aktView()`、`aktSize()`、`view.akt_top、view.akt_width......` 23 | 24 | #### 静态布局 25 | 26 | - 静态布局的基本结构: 27 | ```objective-c 28 | [sub aktLayout:^(AKTLayoutShellAttribute *layout) { 29 | layout.centerXY.equalTo(akt_view(v)); 30 | layout.size.equalTo(akt_view(v)).multiple(.33); 31 | }]; 32 | ``` 33 | 34 | - 基础用法 35 | 36 | `layout.top.left.equalTo(akt_value(0));` 视图的顶部和左边缘坐标值等于0 37 | 38 | `layout.width.equalTo(_tableView.akt_width);` 视图的宽度等于`tableView`的宽度 39 | 40 | `layout.whRatio.equalTo(aktView(_tableView));` 视图的宽高比等于视图`tableView`的宽高比 41 | 42 | `layout.whRatio.equalTo(aktValue(1.0f));` 视图的宽高比等于1.0f 43 | 44 | `layout.size.equalTo(aktView(_tableView));` 视图的宽高等于`_tableView`的宽高 45 | 46 | `layout.edge.equalTo(aktView(_tableView));` 视图的边缘位置等于`_tableView`的边缘位置,即重合 47 | 48 | - 进阶用法 49 | 50 | `layout.top.left.equalTo(akt_value(10)).multiple(1.5);` 视图的顶部和左边缘坐标值等于10*1.5,即15 51 | 52 | `layout.top.left.equalTo(akt_value(10)).multiple(1.5).offset(2);` 视图的顶部和左边缘坐标值等于10*1.5+2,即17 53 | 54 | `layout.top.left.equalTo(akt_value(10)).coefficientOffset(5).multiple(1).offset(2);` 视图的顶部和左边缘坐标值等于(10+5)*1+2,即17 55 | 56 | #### 动态布局 57 | 58 | ![DynamicLayou](https://github.com/AkteamYang/AKTKit.AKTLayout/blob/master/Imgs/Demo/Demo2.gif?raw=true) 59 | > 动态布局更大程度上提高了自动布局的灵活性,你可以与`frame`混合布局。 60 | 61 | - 动态布局的基本结构: 62 | 63 | ```objective-c 64 | AKTWeakView(__self, self); 65 | AKTWeakView(__Img, self.img); 66 | [_title aktLayout:^(AKTLayoutShellAttribute *layout) { 67 | // 动态布局部分 68 | [layout addDynamicLayoutInCondition:^BOOL{ 69 | return mAKT_Portrait; 70 | } andAttribute:^(AKTLayoutShellAttribute *dynamicLayout) { 71 | dynamicLayout.top.centerY.equalTo(akt_view(__self)); 72 | dynamicLayout.left.equalTo(__self.img.akt_right).offset(20); 73 | }]; 74 | [layout addDynamicLayoutInCondition:^BOOL{ 75 | return !mAKT_Portrait; 76 | } andAttribute:^(AKTLayoutShellAttribute *dynamicLayout) { 77 | dynamicLayout.top.equalTo(akt_view(__Img)).offset(10); 78 | dynamicLayout.left.equalTo(__Img.akt_right).offset(20); 79 | }]; 80 | }]; 81 | ``` 82 | - 基本用法 83 | 84 | 动态布局用法和静态一样,只不过调用主体变成`dynamicLayout` ,使用的时候需要把`condition`和`attribute`block用到的视图参照声明为弱引用。 85 | 86 | `dynamicLayout.top.left.equalTo(akt_value(0));` 视图的顶部和左边缘坐标值等于0 87 | 88 | `dynamicLayout.width.equalTo(_tableView.akt_width);` 视图的宽度等于`tableView`的宽度 89 | 90 | `dynamicLayout.whRatio.equalTo(aktView(_tableView));` 视图的宽高比等于视图`tableView`的宽高比 91 | 92 | `dynamicLayout.whRatio.equalTo(aktValue(1.0f));` 视图的宽高比等于1.0f 93 | 94 | `dynamicLayout.size.equalTo(aktView(_tableView));` 视图的宽高等于`_tableView`的宽高 95 | 96 | `dynamicLayout.edge.equalTo(aktView(_tableView));` 视图的边缘位置等于`_tableView`的边缘位置,即重合 97 | 98 | 99 | `dynamicLayout.top.left.equalTo(akt_value(10)).multiple(1.5);` 视图的顶部和左边缘坐标值等于10*1.5,即15 100 | 101 | `dynamicLayout.top.left.equalTo(akt_value(10)).multiple(1.5).offset(2);` 视图的顶部和左边缘坐标值等于10*1.5+2,即17 102 | 103 | `dynamicLayout.top.left.equalTo(akt_value(10)).coefficientOffset(5).multiple(1).offset(2);` 视图的顶部和左边缘坐标值等于(10+5)*1+2,即17 104 | 105 | - 关于`condition`和`attribute` 106 | 107 | 当`condition`返回为`YES`的时候布局将会使用对应的动态布局部分,`condition`block会被频繁调用不应该放置和条件判断无关的操作,`attribute`block只有需要更新动态布局时才会被调用,如果`condition`条件成立,但是上次和本次布局相同,`attribute`也不会被调用。由于二者会被长期持有,我们在`condition`和`attribute`中使用变量时尤其是参考的视图需要声明为弱引用,其他对象的使用可以按照需要决定。 108 | 109 | #### 其他 110 | - 混合布局 111 | 112 | AKTLayout很灵活,在应对复杂布局的时候,支持使用一些`frame`计算,具体的做法是我们给视图添加部分AKTLayout布局,然后在必要的时候我们可以设置`frame`并调用`setNeedAKTLayout`方法来刷新`AKTLayout`的布局,最终得到的将是二者叠加的效果,`Demo`的`interactive page`部分使用了混合布局。 113 | - AKTLayout事件 114 | 115 | AKTLayout提供了布局完成事件接口`- (void)aktDidLayoutTarget:(id)target forSelector:(SEL)selector;`和`- (void)aktDidLayoutWithComplete:(void(^)(UIView *view))complete;`,您可以自己选择方法,`block`会被长期持有,注意循环引用的问题。 116 | 117 | 118 | ### FAQ&Contact 119 | 120 | ------------ 121 | 目前已在9.0系统完成测试,低版本系统后续完成测试。 122 | 123 | 如果您在运行中发现了问题、对有些特性存在疑惑或者有pull request,你可以在[issue](https://github.com/AkteamYang/AKTKit.AKTLayout/issues "issue")创建一个问题。您也可以在我的[简书](http://www.jianshu.com/p/901cde2d4044)中进行评论,或者给我发送邮件battle0001@sina.com。 124 | -------------------------------------------------------------------------------- /Imgs/AKTLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/AKTLayout.jpg -------------------------------------------------------------------------------- /Imgs/AKTLayoutUpdate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/AKTLayoutUpdate.jpg -------------------------------------------------------------------------------- /Imgs/AutoLayout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/AutoLayout.gif -------------------------------------------------------------------------------- /Imgs/Demo/Demo1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/Demo/Demo1.gif -------------------------------------------------------------------------------- /Imgs/Demo/Demo2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/Demo/Demo2.gif -------------------------------------------------------------------------------- /Imgs/Demo/reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/Demo/reference.png -------------------------------------------------------------------------------- /Imgs/addLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/addLayout.jpg -------------------------------------------------------------------------------- /Imgs/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/animation.gif -------------------------------------------------------------------------------- /Imgs/architecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/architecture.jpg -------------------------------------------------------------------------------- /Imgs/compare.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/compare.jpg -------------------------------------------------------------------------------- /Imgs/memory.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/memory.jpg -------------------------------------------------------------------------------- /Imgs/orientation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/orientation.gif -------------------------------------------------------------------------------- /Imgs/reference.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/reference.jpg -------------------------------------------------------------------------------- /Imgs/screenShot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/screenShot.jpg -------------------------------------------------------------------------------- /Imgs/timeCost.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/timeCost.jpg -------------------------------------------------------------------------------- /Imgs/updateLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Imgs/updateLayout.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Test/Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/HaoYang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/HaoYang.xcuserdatad/xcschemes/Test.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/HaoYang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Test.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F8B77AEF1CC27C1F00906CB7 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/YaHaoo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/YaHaoo.xcuserdatad/xcschemes/Test.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/xcuserdata/YaHaoo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Test.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F8B77AEF1CC27C1F00906CB7 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Test/Test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/16. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Test/Test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/16. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController2.h" 11 | #import "AKTNavigationController.h" 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | AKTNavigationController *nv = [[AKTNavigationController alloc]initWithRootViewController:[ViewController2 new]]; 22 | self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; 23 | self.window.rootViewController = nv; 24 | [self.window makeKeyAndVisible]; 25 | [self.window.rootViewController prefersStatusBarHidden]; 26 | // [[UIApplication sharedApplication] setStatusBarHidden:YES]; 27 | return YES; 28 | } 29 | 30 | - (void)applicationWillResignActive:(UIApplication *)application { 31 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 32 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 33 | } 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application { 36 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application { 41 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | - (void)applicationDidBecomeActive:(UIApplication *)application { 45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 46 | } 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Test/Test/Assets.xcassets/AKTLogo.imageset/AKTLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkteamYang/AKTKit.AKTLayout/5a3f605f84f22cc17a7aa981359f3f0d97f13fa9/Test/Test/Assets.xcassets/AKTLogo.imageset/AKTLogo.png -------------------------------------------------------------------------------- /Test/Test/Assets.xcassets/AKTLogo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "AKTLogo.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Test/Test/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Test/Test/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Test/Test/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Test/Test/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Test/Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Test/Test/Masonry/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.cloudling.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Test/Test/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Test/Test/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /Test/Test/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Test/Test/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Test/Test/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Test/Test/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /Test/Test/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /Test/Test/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /Test/Test/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILa 8youtGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Test/Test/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | 19 | - (MASViewAttribute *)mas_bottomLayoutGuide { 20 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 21 | } 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Test/Test/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/16. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AKTKit.h" 11 | @interface ViewController:AKTViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Test/Test/ViewController2.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController2.h 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/20. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AKTKit.h" 11 | 12 | @interface ViewController2:AKTViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Test/Test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Test 4 | // 5 | // Created by YaHaoo on 16/4/16. 6 | // Copyright © 2016年 YaHaoo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------