├── CTUnlimitedView ├── CTUnlimitedView.framework │ ├── _CodeSignature │ │ ├── CodeSignature │ │ ├── CodeDirectory │ │ ├── CodeRequirements │ │ ├── CodeRequirements-1 │ │ └── CodeResources │ ├── Info.plist │ ├── CTUnlimitedView │ ├── Modules │ │ └── module.modulemap │ └── Headers │ │ ├── ViewContainer.h │ │ ├── URLEditor.h │ │ ├── ImageContainer.h │ │ ├── TextEditor.h │ │ ├── BaseContainer.h │ │ ├── RichTextProtocol.h │ │ ├── UUImageCache.h │ │ ├── NSMutableAttributedString+CoreTextMethod.h │ │ ├── CTFrameCreator.h │ │ └── CTUnlimitedView.h ├── Assets.xcassets │ ├── Contents.json │ ├── 1.imageset │ │ ├── 1.jpg │ │ └── Contents.json │ ├── 2.imageset │ │ ├── 2.jpg │ │ └── Contents.json │ ├── 3.imageset │ │ ├── 3.jpg │ │ └── Contents.json │ ├── 4.imageset │ │ ├── 4.jpg │ │ └── Contents.json │ ├── 5.imageset │ │ ├── 5.jpg │ │ └── Contents.json │ ├── 6.imageset │ │ ├── 6.jpg │ │ └── Contents.json │ ├── 7.imageset │ │ ├── 7.jpg │ │ └── Contents.json │ ├── 8.imageset │ │ ├── 8.jpg │ │ └── Contents.json │ ├── 9.imageset │ │ ├── 9.jpg │ │ └── Contents.json │ ├── A.imageset │ │ ├── A.jpeg │ │ └── Contents.json │ ├── 11.imageset │ │ ├── 11.jpg │ │ └── Contents.json │ ├── 33.imageset │ │ ├── 33.jpg │ │ └── Contents.json │ ├── header.imageset │ │ ├── header.jpg │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── BaseViewController.h ├── RichText │ ├── QQViewController.h │ ├── QQInputView.h │ ├── QQRoomModel.h │ ├── QQRoomModel.m │ ├── QQTableViewCell.h │ ├── QQInputView.m │ └── QQTableViewCell.m ├── FPS │ ├── FPSViewController.h │ └── FPSViewController.m ├── Others │ ├── Masonry │ │ ├── MASLayoutConstraint.m │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASCompositeConstraint.h │ │ ├── Masonry.h │ │ ├── ViewController+MASAdditions.h │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewAttribute.h │ │ ├── ViewController+MASAdditions.m │ │ ├── MASViewConstraint.h │ │ ├── MASConstraint+Private.h │ │ ├── NSArray+MASAdditions.h │ │ ├── View+MASShorthandAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── View+MASAdditions.m │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── MASUtilities.h │ │ ├── NSArray+MASAdditions.m │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.m │ │ └── MASViewConstraint.m │ └── YYFPSLabel │ │ ├── YYFPSLabel.h │ │ ├── YYWeakProxy.h │ │ ├── YYWeakProxy.m │ │ └── YYFPSLabel.m ├── AutoLayout │ ├── AutolayoutViewController.h │ └── AutolayoutViewController.m ├── AppDelegate.h ├── TextAroundImages │ ├── TextAroundImagesViewController.h │ └── TextAroundImagesViewController.m ├── main.m ├── RunLoopTool.h ├── CustomHUD.h ├── Info.plist ├── Base.lproj │ └── LaunchScreen.storyboard ├── RunLoopTool.m ├── AppDelegate.m └── BaseViewController.m ├── SC.png ├── README.md ├── CTUnlimitedView.xcodeproj ├── xcuserdata │ ├── boleketang.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── CTUnlimitedView.xcscheme │ └── apple.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── CTUnlimitedView.xcscheme └── project.xcworkspace │ └── contents.xcworkspacedata ├── CTUnlimitedViewTests ├── Info.plist └── CTUnlimitedViewTests.m └── CTUnlimitedViewUITests ├── Info.plist └── CTUnlimitedViewUITests.m /CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeSignature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/SC.png -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CTUnlimitedView 2 | 3 | 做个图文混排的静态库玩 4 | 5 | ![image](https://github.com/zhuochenming/CTUnlimitedView/blob/master/SC.png) 6 | -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/1.imageset/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/1.imageset/1.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/2.imageset/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/2.imageset/2.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/3.imageset/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/3.imageset/3.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/4.imageset/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/4.imageset/4.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/5.imageset/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/5.imageset/5.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/6.imageset/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/6.imageset/6.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/7.imageset/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/7.imageset/7.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/8.imageset/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/8.imageset/8.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/9.imageset/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/9.imageset/9.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/A.imageset/A.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/A.imageset/A.jpeg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/11.imageset/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/11.imageset/11.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/33.imageset/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/33.imageset/33.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/CTUnlimitedView.framework/Info.plist -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/CTUnlimitedView: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/CTUnlimitedView.framework/CTUnlimitedView -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/header.imageset/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/Assets.xcassets/header.imageset/header.jpg -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module CTUnlimitedView { 2 | umbrella header "CTUnlimitedView.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/boleketang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeDirectory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeDirectory -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeRequirements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeRequirements -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeRequirements-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuochenming/CTUnlimitedView/HEAD/CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeRequirements-1 -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CTUnlimitedView/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // QQViewController.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/2/4. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QQViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CTUnlimitedView/FPS/FPSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FPSViewController.h 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/2. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FPSViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/AutoLayout/AutolayoutViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AutolayoutViewController.h 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/28. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AutolayoutViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CTUnlimitedView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/2/15. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end -------------------------------------------------------------------------------- /CTUnlimitedView/TextAroundImages/TextAroundImagesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextAroundImagesViewController.h 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/28. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TextAroundImagesViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/ViewContainer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewContainer.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "BaseContainer.h" 10 | 11 | @interface ViewContainer : BaseContainer 12 | 13 | @property (nonatomic, strong) UIView *view; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQInputView.h: -------------------------------------------------------------------------------- 1 | // 2 | // QQInputView.h 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/22. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QQInputView : UIView 12 | 13 | @property (nonatomic, strong) UITextField *messageTextField; 14 | 15 | @property (nonatomic, strong) UIButton *sendButton; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CTUnlimitedView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 2016/11/1. 6 | // Copyright © 2016年 Zhuochenming. 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 | -------------------------------------------------------------------------------- /CTUnlimitedView/RunLoopTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // RunLoopTool.h 3 | // RunloopTool 4 | // 5 | // Created by Zhuochenming on 16/8/30. 6 | // Copyright © 2016年 Zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RunLoopTool : NSObject 12 | 13 | + (instancetype)defaultRunLoop; 14 | 15 | - (void)addTask:(dispatch_block_t)task key:(id)key; 16 | 17 | - (void)removeAllTasks; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "1.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/11.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "11.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "3.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/33.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "33.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "4.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "5.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "6.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "7.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/8.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "8.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/9.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "9.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/A.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "A.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/header.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "header.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/URLEditor.h: -------------------------------------------------------------------------------- 1 | // 2 | // URLEditor.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "TextEditor.h" 10 | 11 | @interface URLEditor : TextEditor 12 | 13 | @property (nonatomic, assign) CGRect tapRect; 14 | 15 | // 点击链接返回的数据 16 | @property (nonatomic, strong) id linkData; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/YYFPSLabel/YYFPSLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYFPSLabel.h 3 | // YYKitExample 4 | // 5 | // Created by ibireme on 15/9/3. 6 | // Copyright (c) 2015 ibireme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Show Screen FPS... 13 | 14 | The maximum fps in OSX/iOS Simulator is 60.00. 15 | The maximum fps on iPhone is 59.97. 16 | The maxmium fps on iPad is 60.0. 17 | */ 18 | @interface YYFPSLabel : UILabel 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQRoomModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // QQRoomModel.h 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/8/19. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QQRoomModel : NSObject 12 | 13 | @property (nonatomic, strong) NSString *title; 14 | 15 | @property (nonatomic, strong) NSMutableArray *imgNameArray; 16 | 17 | @property (nonatomic, strong) NSMutableArray *imgURLArray; 18 | 19 | @property (nonatomic, strong) NSMutableArray *commentArray; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQRoomModel.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // QQRoomModel.m 4 | // CTUnlimitedView 5 | // 6 | // Created by boleketang on 16/8/19. 7 | // Copyright © 2016年 zhuochenming. All rights reserved. 8 | // 9 | 10 | #import "QQRoomModel.h" 11 | 12 | @implementation QQRoomModel 13 | 14 | - (NSMutableArray *)imgNameArray { 15 | if (_imgNameArray == nil) { 16 | _imgNameArray = [NSMutableArray array]; 17 | } 18 | return _imgNameArray; 19 | } 20 | 21 | - (NSMutableArray *)imgURLArray { 22 | if (_imgURLArray == nil) { 23 | _imgURLArray = [NSMutableArray array]; 24 | } 25 | return _imgURLArray; 26 | } 27 | 28 | - (NSMutableArray *)commentArray { 29 | if (_commentArray == nil) { 30 | _commentArray = [NSMutableArray array]; 31 | } 32 | return _commentArray; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /CTUnlimitedViewTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /CTUnlimitedViewUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/ImageContainer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageContainer.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "BaseContainer.h" 10 | 11 | typedef NS_ENUM(NSUInteger, ImageAlignment) { 12 | ImageAlignmentCenter = 0, // 图片居中 13 | ImageAlignmentLeft = 1, // 图片左对齐 14 | ImageAlignmentRight = 2, // 图片右对齐 15 | }; 16 | 17 | @interface ImageContainer : BaseContainer 18 | 19 | @property (nonatomic, strong) UIImage *image; 20 | 21 | @property (nonatomic, strong) NSString *imageURLString; 22 | //置位图 23 | @property (nonatomic, strong) NSString *placeholdImageName; 24 | //图片下载完成回调 25 | @property (nonatomic, copy) dispatch_block_t block; 26 | 27 | //默认居中 28 | @property (nonatomic, assign) ImageAlignment imageAlignment; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CTUnlimitedView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4F2B6D4E1DC9AEC100038372 16 | 17 | primary 18 | 19 | 20 | 4F2B6D6A1DC9AEC100038372 21 | 22 | primary 23 | 24 | 25 | 4F2B6D751DC9AEC100038372 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/boleketang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CTUnlimitedView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4F2B6D4E1DC9AEC100038372 16 | 17 | primary 18 | 19 | 20 | 4F2B6D6A1DC9AEC100038372 21 | 22 | primary 23 | 24 | 25 | 4F2B6D751DC9AEC100038372 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/TextEditor.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextEditor.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "RichTextProtocol.h" 10 | #import 11 | #import "NSMutableAttributedString+CoreTextMethod.h" 12 | 13 | @interface TextEditor : NSObject 14 | 15 | @property (nonatomic, assign) NSInteger tag; 16 | 17 | @property (nonatomic, assign) NSRange range; 18 | @property (nonatomic, assign) NSRange realRange; 19 | 20 | @property (nonatomic, strong) NSString *text; 21 | @property (nonatomic, strong) UIColor *textColor; 22 | @property (nonatomic, strong) UIFont *font; 23 | 24 | //下划线样式(单 双)(默认没有) 25 | @property (nonatomic, assign) CTUnderlineStyle underLineStyle; 26 | 27 | //下划线样式(点 线)(默认线) 28 | @property (nonatomic, assign) CTUnderlineStyleModifiers modifier; 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /CTUnlimitedViewTests/CTUnlimitedViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CTUnlimitedViewTests.m 3 | // CTUnlimitedViewTests 4 | // 5 | // Created by boleketang on 2016/11/1. 6 | // Copyright © 2016年 Zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CTUnlimitedViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CTUnlimitedViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // QQTableViewCell.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/2/18. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "QQRoomModel.h" 12 | 13 | static CGFloat const QQRoomStaticHeight = 120; 14 | 15 | @interface QQTableViewCell : UITableViewCell 16 | 17 | @property (nonatomic, strong) UIImageView *headImgView; 18 | 19 | @property (nonatomic, strong) UILabel *nameLable; 20 | 21 | @property (nonatomic, strong) CTUnlimitedView *attriLable; 22 | 23 | @property (nonatomic, strong) UIButton *shareButton; 24 | 25 | @property (nonatomic, strong) UIButton *supportButton; 26 | 27 | @property (nonatomic, strong) UIButton *commentButton; 28 | 29 | @property (nonatomic, strong) CTUnlimitedView *commentLable; 30 | 31 | @property (nonatomic, strong) QQRoomModel *model; 32 | 33 | - (void)setContenString:(NSString *)contenString imageNameArray:(NSArray *)imageNameArray urlString:(NSString *)urlstring commentArray:(NSArray *)commentArray; 34 | 35 | - (void)setDataWithContainer:(CTFrameCreator *)container commentArray:(NSArray *)commentArray; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedViewUITests/CTUnlimitedViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CTUnlimitedViewUITests.m 3 | // CTUnlimitedViewUITests 4 | // 5 | // Created by boleketang on 2016/11/1. 6 | // Copyright © 2016年 Zhuochenming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CTUnlimitedViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CTUnlimitedViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/BaseContainer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseContainer.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "RichTextProtocol.h" 10 | 11 | //typedef enum : NSUInteger { 12 | // ContainerAlignmentTop, // 底部齐平 向上伸展 13 | // ContainerAlignmentCenter, // 中心齐平 14 | // ContainerAlignmentBottom, // 顶部齐平 向下伸展 15 | //} ContainerAlignment; 16 | 17 | typedef NS_ENUM(NSUInteger, ContainerAlignment) { 18 | ContainerAlignmentTop, // 底部齐平 向上伸展 19 | ContainerAlignmentCenter, // 中心齐平 20 | ContainerAlignmentBottom, // 顶部齐平 向下伸展 21 | }; 22 | 23 | @interface BaseContainer : NSObject 24 | 25 | @property (nonatomic, assign) NSInteger tag; 26 | 27 | @property (nonatomic, assign) CGRect tapRect; 28 | 29 | @property (nonatomic, assign) NSRange range; 30 | @property (nonatomic, assign) NSRange realRange; 31 | 32 | //画板大小 33 | @property (nonatomic, assign) CGSize size; 34 | //容器四周间距 35 | @property (nonatomic, assign) UIEdgeInsets edge; 36 | 37 | //对齐方式 38 | @property (nonatomic, assign) ContainerAlignment containerAlignment; 39 | 40 | //获取绘画区域上行高度(默认实现) 41 | - (CGFloat)getDrawerAreaAscentHeight; 42 | 43 | //获取绘画区域下行高度 默认实现为0(一般不需要改写) 44 | - (CGFloat)getDrawerAreaDescentHeight; 45 | 46 | //获取绘画区域宽度(默认实现) 47 | - (CGFloat)getDrawerAreaWidth; 48 | 49 | //释放内存 (一般不需要 已注释 需要在打开) 50 | //- (void)DrawRunDealloc; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CTUnlimitedView/CustomHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomHUD.h 3 | // CustomHUD 4 | // 5 | // Created by 酌晨茗 on 16/3/23. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define ConBacColor [UIColor colorWithRed:223 / 255.0 green:223 / 255.0 blue:223 / 255.0 alpha:1] 12 | #define HUDTintColor [UIColor lightGrayColor] 13 | 14 | static CGFloat const HUDOffset = 5.0; 15 | static CGFloat const HUDLeftOffset = 10.0; 16 | static CGFloat const HUDWidth = 130.0; 17 | static CGFloat const HUDHeight = 91.0; 18 | static CGFloat const HUDCircleWidth = 64.0; 19 | static CGFloat const HUDLineWidth = 3.0; 20 | 21 | @interface CustomHUD : UIView 22 | 23 | #pragma mark - 纯文本 24 | + (void)showWithStatus:(NSString *)status; 25 | 26 | #pragma mark - 进度 27 | + (void)showIndicator; 28 | 29 | + (void)showIndicatorWithStatus:(NSString *)status; 30 | 31 | #pragma mark - 进度 32 | + (void)showProgress; 33 | 34 | + (void)showProgressWithStatus:(NSString *)status; 35 | 36 | + (void)showPhysicsProgress; 37 | 38 | + (void)showPhysicsProgressWithStatus:(NSString *)status; 39 | 40 | #pragma mark - 成功 41 | + (void)showSuccess; 42 | 43 | + (void)showSuccessWithStatus:(NSString *)status; 44 | 45 | #pragma mark - 错误 46 | + (void)showError; 47 | 48 | + (void)showErrorWithStatus:(NSString *)status; 49 | 50 | #pragma mark - 移除 51 | + (void)dismiss; 52 | 53 | + (void)dismissAfterTime:(CGFloat)timeout; 54 | 55 | + (void)dismissWithCompletion:(void (^)(void))completion; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/YYFPSLabel/YYWeakProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYWeakProxy.h 3 | // YYKit 4 | // 5 | // Created by ibireme on 14/10/18. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import 13 | 14 | /** 15 | A proxy used to hold a weak object. 16 | It can be used to avoid retain cycles, such as the target in NSTimer or CADisplayLink. 17 | 18 | sample code: 19 | 20 | @implementation MyView { 21 | NSTimer *_timer; 22 | } 23 | 24 | - (void)initTimer { 25 | YYWeakProxy *proxy = [YYWeakProxy proxyWithTarget:self]; 26 | _timer = [NSTimer timerWithTimeInterval:0.1 target:proxy selector:@selector(tick:) userInfo:nil repeats:YES]; 27 | } 28 | 29 | - (void)tick:(NSTimer *)timer {...} 30 | @end 31 | */ 32 | @interface YYWeakProxy : NSProxy 33 | 34 | /** 35 | The proxy target. 36 | */ 37 | @property (nonatomic, weak, readonly) id target; 38 | 39 | /** 40 | Creates a new weak proxy for target. 41 | 42 | @param target Target object. 43 | 44 | @return A new proxy object. 45 | */ 46 | - (instancetype)initWithTarget:(id)target; 47 | 48 | /** 49 | Creates a new weak proxy for target. 50 | 51 | @param target Target object. 52 | 53 | @return A new proxy object. 54 | */ 55 | + (instancetype)proxyWithTarget:(id)target; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/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 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UIStatusBarTintParameters 37 | 38 | UINavigationBar 39 | 40 | Style 41 | UIBarStyleDefault 42 | Translucent 43 | 44 | 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/RichTextProtocol.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // RichTextProtocol.h 4 | // CTUnlimitedView 5 | // 6 | // Created by 酌晨茗 on 16/1/11. 7 | // Copyright © 2016年 酌晨茗. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | #define TICK NSDate *startTime = [NSDate date] 13 | #define TOCK NSLog(@"Time: %f", -[startTime timeIntervalSinceNow]) 14 | 15 | //富文本名(值为Link or Container) 16 | static NSString * const kTextRunAttributedName = @"CTContent"; 17 | 18 | @protocol RichTextProtocol 19 | 20 | @required 21 | 22 | //富文本起始range 23 | @property (nonatomic, assign) NSRange range; 24 | //富文本经过拼接插入等操作后的range 25 | @property (nonatomic, assign) NSRange realRange; 26 | 27 | //添加属性到全文attributedString addContainer调用 28 | - (void)addedIntoAttributedString:(NSMutableAttributedString *)attributedString; 29 | 30 | - (NSMutableAttributedString *)convertToAttributedString; 31 | 32 | @end 33 | 34 | 35 | @protocol ClickableRichTextProtocol 36 | 37 | @required 38 | @property (nonatomic, assign) NSInteger tag; 39 | 40 | @property (nonatomic, assign) CGRect tapRect; 41 | 42 | @end 43 | 44 | //BaseContainer协议 45 | @protocol BaseContainerProtocol 46 | 47 | //四周间距 48 | @property (nonatomic, assign) UIEdgeInsets edge; 49 | 50 | //添加View 或 绘画 到该区域 51 | - (void)drawContainerWithRect:(CGRect)rect context:(CGContextRef)context; 52 | 53 | //设置字体高度 当前字符串替换数 54 | - (void)setTextfontAscent:(CGFloat)ascent descent:(CGFloat)descent; 55 | 56 | @end 57 | 58 | 59 | //ViewContainer和ImageContainer协议 60 | @protocol ViewContainerProtocol 61 | 62 | //传递父类view 63 | - (void)transferHoldView:(UIView *)holderView; 64 | 65 | //不绘制 66 | - (void)didNotDrawRun; 67 | 68 | @end -------------------------------------------------------------------------------- /CTUnlimitedView/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/YYFPSLabel/YYWeakProxy.m: -------------------------------------------------------------------------------- 1 | // 2 | // YYWeakProxy.m 3 | // YYKit 4 | // 5 | // Created by ibireme on 14/10/18. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import "YYWeakProxy.h" 13 | 14 | 15 | @implementation YYWeakProxy 16 | 17 | - (instancetype)initWithTarget:(id)target { 18 | _target = target; 19 | return self; 20 | } 21 | 22 | + (instancetype)proxyWithTarget:(id)target { 23 | return [[YYWeakProxy alloc] initWithTarget:target]; 24 | } 25 | 26 | - (id)forwardingTargetForSelector:(SEL)selector { 27 | return _target; 28 | } 29 | 30 | - (void)forwardInvocation:(NSInvocation *)invocation { 31 | void *null = NULL; 32 | [invocation setReturnValue:&null]; 33 | } 34 | 35 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { 36 | return [NSObject instanceMethodSignatureForSelector:@selector(init)]; 37 | } 38 | 39 | - (BOOL)respondsToSelector:(SEL)aSelector { 40 | return [_target respondsToSelector:aSelector]; 41 | } 42 | 43 | - (BOOL)isEqual:(id)object { 44 | return [_target isEqual:object]; 45 | } 46 | 47 | - (NSUInteger)hash { 48 | return [_target hash]; 49 | } 50 | 51 | - (Class)superclass { 52 | return [_target superclass]; 53 | } 54 | 55 | - (Class)class { 56 | return [_target class]; 57 | } 58 | 59 | - (BOOL)isKindOfClass:(Class)aClass { 60 | return [_target isKindOfClass:aClass]; 61 | } 62 | 63 | - (BOOL)isMemberOfClass:(Class)aClass { 64 | return [_target isMemberOfClass:aClass]; 65 | } 66 | 67 | - (BOOL)conformsToProtocol:(Protocol *)aProtocol { 68 | return [_target conformsToProtocol:aProtocol]; 69 | } 70 | 71 | - (BOOL)isProxy { 72 | return YES; 73 | } 74 | 75 | - (NSString *)description { 76 | return [_target description]; 77 | } 78 | 79 | - (NSString *)debugDescription { 80 | return [_target debugDescription]; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/UUImageCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // UUImageCache.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UUImageCache : NSObject 12 | 13 | //初始化,单例 14 | + (instancetype)sharedCache; 15 | 16 | //图片缓存文件夹 17 | @property (nonatomic, strong, readonly) NSString *imageFilePath; 18 | 19 | //最大并行下载数 20 | @property (nonatomic, assign) NSInteger maxDownloadCount; 21 | 22 | //是否在本地找到图片,是否需要缩略图,如果需要,就返回素略图 23 | //如果不指定缩略图大小,那么就按照屏幕宽度缩放(一般不会出现超出屏幕长度的图片,如果有特殊需求,就自己指定大小) 24 | - (void)imageForURLString:(NSString *)urlstring 25 | needThumImage:(BOOL)needThumImage 26 | found:(void(^)(UIImage *cachedImage, BOOL isDownloadImage))found 27 | notFound:(void(^)())notFound 28 | error:(void(^)())error; 29 | 30 | - (void)imageForURLString:(NSString *)urlstring 31 | needThumImage:(BOOL)needThumImage 32 | thumbImageSize:(CGSize)thumbImageSize 33 | found:(void(^)(UIImage *cachedImage, BOOL isDownloadImage))found 34 | notFound:(void(^)())notFound 35 | error:(void(^)())error; 36 | 37 | //异步直接切成圆角 38 | - (void)imageForURLString:(NSString *)urlstring 39 | needThumImage:(BOOL)needThumImage 40 | radius:(CGFloat)radius 41 | found:(void(^)(UIImage *cachedImage, BOOL isDownloadImage))found 42 | notFound:(void(^)())notFound 43 | error:(void(^)())error; 44 | 45 | - (void)imageForURLString:(NSString *)urlstring 46 | needThumImage:(BOOL)needThumImage 47 | thumbImageSize:(CGSize)thumbImageSize 48 | radius:(CGFloat)radius 49 | found:(void(^)(UIImage *cachedImage, BOOL isDownloadImage))found 50 | notFound:(void(^)())notFound 51 | error:(void(^)())error; 52 | 53 | - (UIImage *)decodedImageWithImage:(UIImage *)image; 54 | 55 | - (void)cancleAllDownLoad; 56 | // 清除cache 57 | - (void)clearCache; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/NSMutableAttributedString+CoreTextMethod.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableAttributedString+CoreTextMethod.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | //对齐方式 13 | static NSString * const kTextRunAlignmentName = @"UUAlignment"; 14 | 15 | @interface NSMutableAttributedString (CoreTextMethod) 16 | 17 | #pragma mark - 文本颜色 18 | - (void)textColor:(UIColor *)color; 19 | - (void)textColor:(UIColor *)color range:(NSRange)range; 20 | 21 | #pragma mark - 空心字样式 22 | - (void)strockTextWidth:(unichar)width; 23 | - (void)strockTextWidth:(unichar)width range:(NSRange)range; 24 | 25 | //设置完空心字宽度后有效 26 | - (void)strockTextColor:(UIColor *)color; 27 | - (void)strockTextColor:(UIColor *)color range:(NSRange)range; 28 | 29 | #pragma mark - 文本字体 30 | - (void)font:(UIFont *)font; 31 | - (void)font:(UIFont *)font range:(NSRange)range; 32 | 33 | - (void)italicAngle:(CGFloat)angle fontSize:(CGFloat)fontSize; 34 | - (void)italicAngle:(CGFloat)angle fontSize:(CGFloat)fontSize range:(NSRange)range; 35 | 36 | #pragma mark - 文本字符间隔 37 | - (void)characterSpacing:(unichar)characterSpacing; 38 | - (void)characterSpacing:(unichar)characterSpacing range:(NSRange)range; 39 | 40 | #pragma mark - 下划线样式 41 | - (void)underlineStyle:(CTUnderlineStyle)style modifier:(CTUnderlineStyleModifiers)modifier; 42 | - (void)underlineStyle:(CTUnderlineStyle)style modifier:(CTUnderlineStyleModifiers)modifier range:(NSRange)range; 43 | 44 | - (void)underlineColor:(UIColor *)color; 45 | - (void)underlineColor:(UIColor *)color range:(NSRange)range; 46 | 47 | #pragma mark - 文本段落样式 48 | - (void)alignmentStyle:(CTTextAlignment)textAlignment lineSpaceStyle:(CGFloat)linesSpacing paragraphSpaceStyle:(CGFloat)paragraphSpacing lineBreakStyle:(CTLineBreakMode)lineBreakMode; 49 | - (void)alignmentStyle:(CTTextAlignment)textAlignment lineSpaceStyle:(CGFloat)linesSpacing paragraphSpaceStyle:(CGFloat)paragraphSpacing lineBreakStyle:(CTLineBreakMode)lineBreakMode range:(NSRange)range; 50 | 51 | #pragma mark - 分页 52 | - (NSRange)pageRangeWithSize:(CGSize)size from:(NSInteger)location; 53 | - (NSArray *)pageRangeArrayWithSize:(CGSize)size; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /CTUnlimitedView/FPS/FPSViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FPSViewController.m 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/2. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import "FPSViewController.h" 10 | 11 | static NSString *cellIdentifier = @"Cell"; 12 | 13 | @interface FPSViewController () 14 | 15 | @property (nonatomic, strong) UITableView *tableView; 16 | 17 | @end 18 | 19 | @implementation FPSViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | self.navigationItem.title = @"帧数测试"; 26 | 27 | self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain]; 28 | self.tableView.tableFooterView = [UIView new]; 29 | self.tableView.backgroundColor = self.view.backgroundColor; 30 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier]; 31 | 32 | self.tableView.delegate = self; 33 | self.tableView.dataSource = self; 34 | self.tableView.translatesAutoresizingMaskIntoConstraints = NO; 35 | [self.view addSubview:_tableView]; 36 | // Do any additional setup after loading the view. 37 | } 38 | 39 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 40 | return 300; 41 | } 42 | 43 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 44 | return 150; 45 | } 46 | 47 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 48 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; 49 | cell.backgroundColor = [UIColor whiteColor]; 50 | cell.textLabel.text = [NSString stringWithFormat:@"indexPath%ld", indexPath.row]; 51 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 52 | return cell; 53 | } 54 | 55 | 56 | - (void)didReceiveMemoryWarning { 57 | [super didReceiveMemoryWarning]; 58 | // Dispose of any resources that can be recreated. 59 | } 60 | 61 | /* 62 | #pragma mark - Navigation 63 | 64 | // In a storyboard-based application, you will often want to do a little preparation before navigation 65 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 66 | // Get the new view controller using [segue destinationViewController]. 67 | // Pass the selected object to the new view controller. 68 | } 69 | */ 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /CTUnlimitedView/RunLoopTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // RunLoopTool.m 3 | // RunloopTool 4 | // 5 | // Created by Zhuochenming on 16/8/30. 6 | // Copyright © 2016年 Zhuochenming. All rights reserved. 7 | // 8 | 9 | #import "RunLoopTool.h" 10 | 11 | @interface RunLoopTool() 12 | 13 | @property (nonatomic, assign) CFRunLoopObserverRef observer; 14 | 15 | @property (nonatomic, strong) NSMutableArray *tasks; 16 | @property (nonatomic, strong) NSMutableArray *tasksKeys; 17 | 18 | @end 19 | 20 | @implementation RunLoopTool 21 | 22 | + (instancetype)defaultRunLoop { 23 | static RunLoopTool *tool = nil; 24 | static dispatch_once_t onceToken; 25 | dispatch_once(&onceToken, ^{ 26 | tool = [[RunLoopTool alloc] init]; 27 | }); 28 | return tool; 29 | } 30 | 31 | - (instancetype)init { 32 | if ((self = [super init])) { 33 | _tasks = [NSMutableArray array]; 34 | _tasksKeys = [NSMutableArray array]; 35 | _observer = CFRunLoopObserverCreateWithHandler(kCFAllocatorDefault, kCFRunLoopBeforeWaiting | kCFRunLoopExit, YES, LONG_MAX,^(CFRunLoopObserverRef observer, CFRunLoopActivity _) { 36 | [self performSelector:@selector(runLoopWorkTaskCallBack:) onThread:[NSThread mainThread] withObject:self waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 37 | }); 38 | } 39 | return self; 40 | } 41 | 42 | - (void)runLoopWorkTaskCallBack:(RunLoopTool *)runLoopTool { 43 | if (runLoopTool.tasks.count != 0) { 44 | dispatch_block_t unit = runLoopTool.tasks.firstObject; 45 | unit(); 46 | [runLoopTool.tasks removeObjectAtIndex:0]; 47 | [runLoopTool.tasksKeys removeObjectAtIndex:0]; 48 | 49 | if (runLoopTool.tasks.count == 0) { 50 | CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), _observer, kCFRunLoopCommonModes); 51 | } 52 | } 53 | } 54 | 55 | - (void)addTask:(dispatch_block_t)task key:(id)key { 56 | if (!CFRunLoopContainsObserver(CFRunLoopGetCurrent(), _observer, kCFRunLoopCommonModes)) { 57 | CFRunLoopAddObserver(CFRunLoopGetCurrent(), _observer, kCFRunLoopCommonModes); 58 | } 59 | [self.tasks addObject:task]; 60 | [self.tasksKeys addObject:key]; 61 | } 62 | 63 | - (void)removeAllTasks { 64 | CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), _observer, kCFRunLoopCommonModes); 65 | [self.tasks removeAllObjects]; 66 | [self.tasksKeys removeAllObjects]; 67 | } 68 | 69 | //- (void)dealloc { 70 | // CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), _observer, kCFRunLoopCommonModes); 71 | // CFRelease(_observer); 72 | //} 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/YYFPSLabel/YYFPSLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // YYFPSLabel.m 3 | // YYKitExample 4 | // 5 | // Created by ibireme on 15/9/3. 6 | // Copyright (c) 2015 ibireme. All rights reserved. 7 | // 8 | 9 | #import "YYFPSLabel.h" 10 | #import "YYWeakProxy.h" 11 | 12 | #define kSize CGSizeMake(55, 20) 13 | 14 | @implementation YYFPSLabel { 15 | CADisplayLink *_link; 16 | NSUInteger _count; 17 | NSTimeInterval _lastTime; 18 | UIFont *_font; 19 | UIFont *_subFont; 20 | 21 | NSTimeInterval _llll; 22 | } 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame { 25 | if (frame.size.width == 0 && frame.size.height == 0) { 26 | frame.size = kSize; 27 | } 28 | self = [super initWithFrame:frame]; 29 | 30 | self.layer.cornerRadius = 5; 31 | self.clipsToBounds = YES; 32 | self.textAlignment = NSTextAlignmentCenter; 33 | self.userInteractionEnabled = NO; 34 | self.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.700]; 35 | 36 | _font = [UIFont fontWithName:@"Menlo" size:14]; 37 | if (_font) { 38 | _subFont = [UIFont fontWithName:@"Menlo" size:4]; 39 | } else { 40 | _font = [UIFont fontWithName:@"Courier" size:14]; 41 | _subFont = [UIFont fontWithName:@"Courier" size:4]; 42 | } 43 | 44 | // 如果直接用 self 或者 weakSelf,都不能解决循环引用问题 45 | _link = [CADisplayLink displayLinkWithTarget:[YYWeakProxy proxyWithTarget:self] selector:@selector(tick:)]; 46 | // __weak typeof(self) weakSelf = self; 47 | // _link = [CADisplayLink displayLinkWithTarget:weakSelf selector:@selector(tick:)]; 48 | [_link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 49 | return self; 50 | } 51 | 52 | - (void)dealloc { 53 | [_link invalidate]; 54 | NSLog(@"timer release"); 55 | } 56 | 57 | - (CGSize)sizeThatFits:(CGSize)size { 58 | return kSize; 59 | } 60 | 61 | - (void)tick:(CADisplayLink *)link { 62 | if (_lastTime == 0) { 63 | _lastTime = link.timestamp; 64 | return; 65 | } 66 | 67 | _count++; 68 | NSTimeInterval delta = link.timestamp - _lastTime; 69 | if (delta < 1) return; 70 | _lastTime = link.timestamp; 71 | float fps = _count / delta; 72 | _count = 0; 73 | 74 | CGFloat progress = fps / 60.0; 75 | UIColor *color = [UIColor colorWithHue:0.27 * (progress - 0.2) saturation:1 brightness:0.9 alpha:1]; 76 | 77 | NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d FPS",(int)round(fps)]]; 78 | [text addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, text.length - 3)]; 79 | [text addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(text.length - 3, 3)]; 80 | [text addAttribute:NSFontAttributeName value:_font range:NSMakeRange(0, text.length)]; 81 | [text addAttribute:NSFontAttributeName value:_subFont range:NSMakeRange(text.length - 4, 1)]; 82 | self.attributedText = text; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQInputView.m: -------------------------------------------------------------------------------- 1 | // 2 | // QQInputView.m 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/22. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import "QQInputView.h" 10 | 11 | static CGFloat const MessageOffset = 10; 12 | static CGFloat const ContentHeight = 30; 13 | 14 | #define LineColor [UIColor colorWithRed:217 / 255.0 green:217 / 255.0 blue:217 / 255.0 alpha:1] 15 | 16 | @implementation QQInputView 17 | 18 | - (instancetype)initWithFrame:(CGRect)frame { 19 | self = [super initWithFrame:frame]; 20 | if (self) { 21 | self.backgroundColor = [UIColor colorWithRed:234 / 255.0 green:234 / 255.0 blue:234 / 255.0 alpha:1]; 22 | 23 | CGFloat width = frame.size.width; 24 | CGFloat height = frame.size.height; 25 | CGFloat top = (height - ContentHeight) / 2.0; 26 | 27 | UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 1.0)]; 28 | lineView.backgroundColor = LineColor; 29 | [self addSubview:lineView]; 30 | 31 | self.messageTextField = [[UITextField alloc] initWithFrame:CGRectMake(MessageOffset, top, width - 12 * MessageOffset, ContentHeight)]; 32 | self.messageTextField.textColor = [UIColor lightGrayColor]; 33 | self.messageTextField.font = [UIFont systemFontOfSize:14]; 34 | 35 | [self setCenterPlaceholder]; 36 | 37 | self.messageTextField.borderStyle = UITextBorderStyleRoundedRect; 38 | [self addSubview:_messageTextField]; 39 | 40 | 41 | self.sendButton = [UIButton buttonWithType:UIButtonTypeSystem]; 42 | self.sendButton.frame = CGRectMake(width - 60, top, 50, ContentHeight); 43 | [self.sendButton setTitle:@"发送" forState:UIControlStateNormal]; 44 | 45 | UIColor *defaultColor = [UIColor colorWithRed:10 / 255.0 green:104 / 255.0 blue:255 / 255.0 alpha:1]; 46 | [self.sendButton setTitleColor:defaultColor forState:UIControlStateNormal]; 47 | 48 | self.sendButton.layer.cornerRadius = 5; 49 | [self.sendButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 50 | self.sendButton.backgroundColor = [UIColor whiteColor]; 51 | [self.sendButton.titleLabel setFont:[UIFont systemFontOfSize:16]]; 52 | [self addSubview:_sendButton]; 53 | } 54 | return self; 55 | } 56 | 57 | - (void)setCenterPlaceholder { 58 | NSMutableParagraphStyle *style = [self.messageTextField.defaultTextAttributes[NSParagraphStyleAttributeName] mutableCopy]; 59 | style.minimumLineHeight = self.messageTextField.font.lineHeight - (self.messageTextField.font.lineHeight - [UIFont systemFontOfSize:14].lineHeight) / 2.0; 60 | 61 | self.messageTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"说点什么吧..." attributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName : [UIFont systemFontOfSize:14], NSParagraphStyleAttributeName : style}]; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 | -------------------------------------------------------------------------------- /CTUnlimitedView/AutoLayout/AutolayoutViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AutolayoutViewController.m 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/28. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import "AutolayoutViewController.h" 10 | #import 11 | #import "Masonry.h" 12 | 13 | @interface AutolayoutViewController () 14 | 15 | @end 16 | 17 | @implementation AutolayoutViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | self.view.backgroundColor = [UIColor lightGrayColor]; 22 | self.edgesForExtendedLayout = UIRectEdgeNone; 23 | 24 | NSString *text = @"小七:我是一枚萌萌哒的逗比,我是一枚萌萌哒的逗比,我是一枚萌萌哒的逗比,重要的事说三遍\n"; 25 | 26 | NSArray *array = @[text, text, text, text]; 27 | NSMutableAttributedString *attString = [self commentLableWithArray:array]; 28 | CTUnlimitedView *ctView = [[CTUnlimitedView alloc] init]; 29 | ctView.attributedText = attString; 30 | ctView.tag = 300; 31 | // CTUnlimitedView.numberOfLines = 3; 32 | ctView.lineBreakMode = kCTLineBreakByTruncatingTail; 33 | ctView.delegate = self; 34 | [self.view addSubview:ctView]; 35 | 36 | ctView.isUseAutoLayout = YES; 37 | [ctView mas_makeConstraints:^(MASConstraintMaker *make) { 38 | make.top.equalTo(self.view).offset(0); 39 | make.left.mas_equalTo(15); 40 | make.right.mas_equalTo(-15); 41 | }]; 42 | // Do any additional setup after loading the view. 43 | } 44 | 45 | - (NSMutableAttributedString *)commentLableWithArray:(NSArray *)commintArray { 46 | // self.commentLable.attributedText = [NSMutableAttributedString new]; 47 | NSMutableAttributedString *mAttString = [NSMutableAttributedString new]; 48 | for (int i = 0; i < commintArray.count; i++) { 49 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:commintArray[i]]; 50 | [attString alignmentStyle:kCTTextAlignmentJustified lineSpaceStyle:1 paragraphSpaceStyle:15.0 lineBreakStyle:kCTLineBreakByClipping range:NSMakeRange(0, 3)]; 51 | [attString underlineColor:[UIColor redColor] range:NSMakeRange(0, 3)]; 52 | [attString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)]; 53 | [mAttString appendAttributedString:attString]; 54 | } 55 | return mAttString; 56 | } 57 | 58 | - (void)CTUnlimitedView:(CTUnlimitedView *)CTUnlimitedView textContainerClicked:(id)textContainer atPoint:(CGPoint)point { 59 | 60 | } 61 | 62 | - (void)didReceiveMemoryWarning { 63 | [super didReceiveMemoryWarning]; 64 | // Dispose of any resources that can be recreated. 65 | } 66 | 67 | /* 68 | #pragma mark - Navigation 69 | 70 | // In a storyboard-based application, you will often want to do a little preparation before navigation 71 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 72 | // Get the new view controller using [segue destinationViewController]. 73 | // Pass the selected object to the new view controller. 74 | } 75 | */ 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/CTFrameCreator.h: -------------------------------------------------------------------------------- 1 | // 2 | // CTFrameCreator.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RichTextProtocol.h" 11 | 12 | //文本处理 13 | #import "TextEditor.h" 14 | #import "URLEditor.h" 15 | 16 | //view容器 17 | #import "BaseContainer.h" 18 | #import "ViewContainer.h" 19 | #import "ImageContainer.h" 20 | 21 | @interface CTFrameCreator : NSObject 22 | 23 | @property (nonatomic, strong) NSString *text; 24 | @property (nonatomic, strong) NSMutableAttributedString *attributedText; 25 | 26 | @property (nonatomic, strong) UIColor *textColor; 27 | @property (nonatomic, strong) UIColor *linkColor; 28 | 29 | @property (nonatomic, strong) UIFont *font; 30 | 31 | @property (nonatomic, assign) NSInteger numberOfLines; 32 | @property (nonatomic, assign) unichar characterSpacing; 33 | @property (nonatomic, assign) CGFloat linesSpacing; 34 | @property (nonatomic, assign) CGFloat paragraphSpacing; 35 | 36 | @property (nonatomic, assign) CTTextAlignment textAlignment; 37 | @property (nonatomic, assign) CTLineBreakMode lineBreakMode; 38 | 39 | @property (nonatomic, strong) NSArray *exclusionRectArray; 40 | 41 | @property (nonatomic, strong, readonly) NSArray *textContainerArray; 42 | //调用- (CTFrameRef)getFrameRefWithSize:(CGSize)size方法后有值 43 | @property (nonatomic, assign, readonly) CTFrameRef frameRef; 44 | 45 | #pragma mark - 文本 46 | - (void)insertText:(NSString *)text location:(NSInteger)location; 47 | - (void)insertAttributedString:(NSAttributedString *)attributedText location:(NSInteger)location; 48 | 49 | - (void)appendText:(NSString *)text; 50 | - (void)appendAttributedString:(NSAttributedString *)attributedText; 51 | 52 | - (void)addTextEditor:(TextEditor *)textEditor; 53 | - (void)appendTextEditor:(TextEditor *)textEditor; 54 | 55 | #pragma mark - 容器 56 | - (void)addContainer:(BaseContainer *)container; 57 | - (void)appendContainer:(BaseContainer *)container; 58 | 59 | #pragma mark - 获取文本高度 60 | - (CGFloat)getSuggestHeightWithWidth:(CGFloat)width; 61 | 62 | #pragma mark - 生成frameFef 63 | - (CTFrameRef)getFrameRefWithSize:(CGSize)size; 64 | 65 | #pragma mark - 遍历 66 | - (id)richTextWithTag:(NSInteger)tag; 67 | 68 | - (BOOL)isHaveClickableRichText; 69 | - (BOOL)isHaveClickableLink; 70 | - (BOOL)isHaveClickableContainer; 71 | 72 | - (void)traversalContainer:(void(^)(BaseContainer *container, CGRect rect))block; 73 | - (BOOL)traversalLinkOfClickPoint:(CGPoint)point viewHeight:(CGFloat)viewHeight callBack:(void (^)(URLEditor *linkText))block; 74 | 75 | - (BOOL)enumerateRunRectContainPoint:(CGPoint)point viewHeight:(CGFloat)viewHeight successBlock:(void (^)(id textContainer))successBlock; 76 | 77 | //根据point获取点击的CTRun的location 78 | - (NSInteger)locationOfCTRunWithPoint:(CGPoint)point rect:(CGRect)rect; 79 | //根据point获取点击的CTRun的range 80 | - (NSRange)rangeOfCTRunWithPoint:(CGPoint)point rect:(CGRect)rect; 81 | //根据range获取CTRun的rect 82 | - (CGRect)rectOfCTRunWithRange:(NSRange)range size:(CGSize)size; 83 | - (void)resetLocation; 84 | //合并range 85 | - (void)combineSelectedRangeArray:(NSMutableArray *)rangeArray newRange:(NSRange)newRange; 86 | 87 | #pragma mark - 重置CTFrameRef 88 | - (void)resetFrameRef; 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /CTUnlimitedView/TextAroundImages/TextAroundImagesViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TextAroundImagesViewController.m 3 | // CTUnlimitedView 4 | // 5 | // Created by boleketang on 16/9/28. 6 | // Copyright © 2016年 zhuochenming. All rights reserved. 7 | // 8 | 9 | #import "TextAroundImagesViewController.h" 10 | #import 11 | 12 | @interface TextAroundImagesViewController () 13 | 14 | @property (nonatomic, assign) CTUnlimitedView *attLable; 15 | 16 | @end 17 | 18 | @implementation TextAroundImagesViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // self.view.backgroundColor = [UIColor colorWithRed:244 / 255.0 green:244 / 255.0 blue:244 / 255.0 alpha:1]; 23 | self.view.backgroundColor = [UIColor lightGrayColor]; 24 | 25 | self.edgesForExtendedLayout = UIRectEdgeNone; 26 | 27 | CGRect viewRect = CGRectMake(30, 50, 50, 50); 28 | CGFloat viewWidth = CGRectGetWidth(self.view.frame) - 30; 29 | 30 | NSString *text = @"总有一天你将破蛹而出,成长得比人们期待的还要美丽。但这个过程会很痛,会很辛苦,有时候还会觉得灰心。面对着汹涌而来的现实,觉得自己渺小无力。但这,也是生命的一部分。做好现在你能做的,然后,一切都会好的。我们都将孤独地长大,不要害怕。"; 31 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:text]; 32 | [attString alignmentStyle:kCTLeftTextAlignment lineSpaceStyle:10 paragraphSpaceStyle:10 lineBreakStyle:0]; 33 | [attString textColor:[UIColor lightGrayColor]]; 34 | [attString font:[UIFont systemFontOfSize:16]]; 35 | 36 | CTUnlimitedView *ctView = [[CTUnlimitedView alloc] init]; 37 | ctView.attributedText = attString; 38 | ctView.exclusionRectArray = @[NSStringFromCGRect(viewRect)]; 39 | ctView.tag = 300; 40 | ctView.delegate = self; 41 | ctView.frame = CGRectMake(15, 10, viewWidth, [ctView getHeightWithWidth:viewWidth]); 42 | // CTUnlimitedView.backgroundColor = [UIColor orangeColor]; 43 | [self.view addSubview:ctView]; 44 | 45 | UIImageView *imgView = [[UIImageView alloc] initWithFrame:viewRect]; 46 | imgView.backgroundColor = [UIColor redColor]; 47 | imgView.userInteractionEnabled = YES; 48 | imgView.image = [UIImage imageNamed:@"33.jpg"]; 49 | imgView.contentMode = UIViewContentModeScaleAspectFit; 50 | UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panView:)]; 51 | [imgView addGestureRecognizer:panGesture]; 52 | [ctView addSubview:imgView]; 53 | 54 | 55 | _attLable = ctView; 56 | 57 | // Do any additional setup after loading the view. 58 | } 59 | 60 | - (void)CTUnlimitedView:(CTUnlimitedView *)CTUnlimitedView textContainerClicked:(id)textContainer atPoint:(CGPoint)point { 61 | 62 | } 63 | 64 | - (void)panView:(UIPanGestureRecognizer *)pan { 65 | CGPoint point = [pan locationInView:_attLable]; 66 | 67 | pan.view.center = point; 68 | _attLable.exclusionRectArray = @[NSStringFromCGRect(pan.view.frame)]; 69 | [_attLable.frameCreator resetFrameRef]; 70 | [_attLable setNeedsDisplay]; 71 | } 72 | 73 | - (void)didReceiveMemoryWarning { 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | /* 79 | #pragma mark - Navigation 80 | 81 | // In a storyboard-based application, you will often want to do a little preparation before navigation 82 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 83 | // Get the new view controller using [segue destinationViewController]. 84 | // Pass the selected object to the new view controller. 85 | } 86 | */ 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if TARGET_OS_IPHONE || TARGET_OS_TV 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 53 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 54 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 55 | 56 | @end 57 | 58 | #define MAS_ATTR_FORWARD(attr) \ 59 | - (MASViewAttribute *)attr { \ 60 | return [self mas_##attr]; \ 61 | } 62 | 63 | @implementation MAS_VIEW (MASShorthandAdditions) 64 | 65 | MAS_ATTR_FORWARD(top); 66 | MAS_ATTR_FORWARD(left); 67 | MAS_ATTR_FORWARD(bottom); 68 | MAS_ATTR_FORWARD(right); 69 | MAS_ATTR_FORWARD(leading); 70 | MAS_ATTR_FORWARD(trailing); 71 | MAS_ATTR_FORWARD(width); 72 | MAS_ATTR_FORWARD(height); 73 | MAS_ATTR_FORWARD(centerX); 74 | MAS_ATTR_FORWARD(centerY); 75 | MAS_ATTR_FORWARD(baseline); 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 78 | 79 | MAS_ATTR_FORWARD(firstBaseline); 80 | MAS_ATTR_FORWARD(lastBaseline); 81 | 82 | #endif 83 | 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | 86 | MAS_ATTR_FORWARD(leftMargin); 87 | MAS_ATTR_FORWARD(rightMargin); 88 | MAS_ATTR_FORWARD(topMargin); 89 | MAS_ATTR_FORWARD(bottomMargin); 90 | MAS_ATTR_FORWARD(leadingMargin); 91 | MAS_ATTR_FORWARD(trailingMargin); 92 | MAS_ATTR_FORWARD(centerXWithinMargins); 93 | MAS_ATTR_FORWARD(centerYWithinMargins); 94 | 95 | #endif 96 | 97 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 98 | return [self mas_attribute]; 99 | } 100 | 101 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 102 | return [self mas_makeConstraints:block]; 103 | } 104 | 105 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 106 | return [self mas_updateConstraints:block]; 107 | } 108 | 109 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 110 | return [self mas_remakeConstraints:block]; 111 | } 112 | 113 | @end 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if TARGET_OS_IPHONE || TARGET_OS_TV 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | /** 56 | * a key to associate with this view 57 | */ 58 | @property (nonatomic, strong) id mas_key; 59 | 60 | /** 61 | * Finds the closest common superview between this view and another view 62 | * 63 | * @param view other view 64 | * 65 | * @return returns nil if common superview could not be found 66 | */ 67 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 68 | 69 | /** 70 | * Creates a MASConstraintMaker with the callee view. 71 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 72 | * 73 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 74 | * 75 | * @return Array of created MASConstraints 76 | */ 77 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 82 | * If an existing constraint exists then it will be updated instead. 83 | * 84 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 85 | * 86 | * @return Array of created/updated MASConstraints 87 | */ 88 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 89 | 90 | /** 91 | * Creates a MASConstraintMaker with the callee view. 92 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 93 | * All constraints previously installed for the view will be removed. 94 | * 95 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 96 | * 97 | * @return Array of created/updated MASConstraints 98 | */ 99 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /CTUnlimitedView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/2/15. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "BaseViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | 23 | BaseViewController *base = [[BaseViewController alloc] init]; 24 | UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:base]; 25 | self.window.rootViewController = navigationController; 26 | [self.window makeKeyAndVisible]; 27 | 28 | // dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 29 | // dispatch_group_t group = dispatch_group_create(); 30 | // dispatch_group_async(group, quene, ^{ 31 | // for (int i = 0; i < 10; i++) { 32 | // NSLog(@"%ld", i); 33 | // } 34 | // }); 35 | // dispatch_group_async(group, quene, ^{ 36 | // for (int i = 0; i < 10; i++) { 37 | // NSLog(@"~~~~~%ld", i); 38 | // } 39 | // }); 40 | // 41 | // dispatch_barrier_async(quene, ^{ 42 | // NSLog(@"你是"); 43 | // }); 44 | // 45 | // dispatch_barrier_async(quene, ^{ 46 | // NSLog(@"逗比"); 47 | // }); 48 | // 49 | // dispatch_async(quene, ^{ 50 | // NSLog(@"我"); 51 | // }); 52 | // 53 | // dispatch_async(quene, ^{ 54 | // NSLog(@"不值得"); 55 | // }); 56 | 57 | // dispatch_group_notify(group, dispatch_get_main_queue(), ^{ 58 | // NSLog(@"END"); 59 | // }); 60 | 61 | // dispatch_barrier_async的顺序执行依赖queue的类型,必需要queue的类型为dispatch_queue_create创建,而且attr参数值必需是DISPATCH_QUEUE_CONCURRENT类型,前面两个非dispatch_barrier_async的类型的执行是依赖其本身的执行时间 62 | // const char *queueName = [@"fdsg" UTF8String]; 63 | // dispatch_queue_t queue = dispatch_queue_create(queueName, 0); 64 | // 65 | // dispatch_async(queue, ^{ 66 | // [NSThread sleepForTimeInterval:3]; 67 | // NSLog(@"dispatch_async1"); 68 | // }); 69 | // dispatch_async(queue, ^{ 70 | //// [NSThread sleepForTimeInterval:1]; 71 | // NSLog(@"dispatch_async2"); 72 | // }); 73 | // dispatch_barrier_async(queue, ^{ 74 | // NSLog(@"dispatch_barrier_async"); 75 | // [NSThread sleepForTimeInterval:0.5]; 76 | // 77 | // }); 78 | // dispatch_async(queue, ^{ 79 | // [NSThread sleepForTimeInterval:1]; 80 | // NSLog(@"dispatch_async3"); 81 | // }); 82 | 83 | return YES; 84 | } 85 | 86 | - (void)applicationWillResignActive:(UIApplication *)application { 87 | // 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. 88 | // 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. 89 | } 90 | 91 | - (void)applicationDidEnterBackground:(UIApplication *)application { 92 | // 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. 93 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 94 | } 95 | 96 | - (void)applicationWillEnterForeground:(UIApplication *)application { 97 | // 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. 98 | } 99 | 100 | - (void)applicationDidBecomeActive:(UIApplication *)application { 101 | // 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. 102 | } 103 | 104 | - (void)applicationWillTerminate:(UIApplication *)application { 105 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/CTUnlimitedView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /CTUnlimitedView.xcodeproj/xcuserdata/boleketang.xcuserdatad/xcschemes/CTUnlimitedView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/Headers/CTUnlimitedView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CTUnlimitedView.h 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CTFrameCreator.h" 11 | 12 | typedef NS_ENUM(NSInteger, DrawType) { 13 | DrawTextAndPicture, // 图文混排 14 | DrawPureText, // 只绘制纯文本 15 | }; 16 | 17 | @class CTUnlimitedView; 18 | @protocol CTUnlimitedViewDelegate 19 | 20 | @optional 21 | - (void)CTUnlimitedViewSelected:(CTUnlimitedView *)CTUnlimitedView; 22 | 23 | - (void)CTUnlimitedView:(CTUnlimitedView *)CTUnlimitedView textContainerClicked:(id)textContainer atPoint:(CGPoint)point; 24 | 25 | - (void)CTUnlimitedView:(CTUnlimitedView *)CTUnlimitedView textContainerLongPressed:(id)textContainer onState:(UIGestureRecognizerState)state atPoint:(CGPoint)point; 26 | 27 | @end 28 | 29 | @interface CTUnlimitedView : UIView 30 | 31 | @property (nonatomic, assign) id delegate; 32 | 33 | //混排类型, 应排版前优先设置 34 | @property (nonatomic, assign) DrawType drawType; 35 | 36 | //文本 37 | @property (nonatomic, strong) NSString *text; 38 | @property (nonatomic, strong) NSMutableAttributedString *attributedText; 39 | 40 | //容器 41 | @property (nonatomic, strong) CTFrameCreator *frameCreator; 42 | 43 | //不规则的路径导致布局不美观,所以设定为矩形 44 | @property (nonatomic, strong) NSArray *exclusionRectArray; 45 | 46 | //lable属性,参照lable用法 47 | @property (nonatomic, strong) UIColor *textColor; 48 | @property (nonatomic, strong) UIFont *font; 49 | @property (nonatomic, assign) NSInteger numberOfLines; 50 | 51 | //链接文本属性 52 | @property (nonatomic, strong) UIColor *linkColor; 53 | @property (nonatomic, strong) UIColor *highlightedLinkColor; 54 | 55 | //是否支持复制,默认为YES 56 | @property (nonatomic, assign) BOOL isCopyAvailable; 57 | 58 | //高亮色 selectedRadius默认为3 59 | @property (nonatomic, assign) CGFloat selectedRadius; 60 | @property (nonatomic, strong) UIColor *selectColor; 61 | 62 | //链接点击高亮色 一起设置才有效 radius默认为3 63 | @property (nonatomic, strong) UIColor *linkBackgroundColor; 64 | @property (nonatomic, assign) CGFloat linkBackgroundRadius; 65 | 66 | //文字间距对齐方式 67 | @property (nonatomic, assign) unichar characterSpacing; 68 | @property (nonatomic, assign) CGFloat linesSpacing; 69 | @property (nonatomic, assign) CGFloat paragraphSpacing; 70 | 71 | //CoreText方法,属性以kCT开头 72 | @property (nonatomic, assign) CTTextAlignment textAlignment; 73 | @property (nonatomic, assign) CTLineBreakMode lineBreakMode; 74 | 75 | //是否使用autoLayout,默认NO(性能有损失) 76 | @property (nonatomic, assign) BOOL isUseAutoLayout; 77 | 78 | //根据tag获取添加的对象 79 | - (id)richTextWithTag:(NSInteger)tag; 80 | 81 | #pragma mark - 处理文本 82 | - (void)insertText:(NSString *)text location:(NSInteger)location; 83 | - (void)insertAttributedString:(NSAttributedString *)attributedText location:(NSInteger)location; 84 | 85 | - (void)appendText:(NSString *)text; 86 | - (void)appendAttributedString:(NSAttributedString *)attributedText; 87 | 88 | #pragma mark - 文本链接 89 | - (void)addTextEditor:(TextEditor *)textEditor; 90 | - (void)appendTextEditor:(TextEditor *)textEditor; 91 | 92 | - (URLEditor *)insertLinkWithLinkData:(id)linkData linkColor:(UIColor *)linkColor underLineStyle:(CTUnderlineStyle)underLineStyle range:(NSRange )range; 93 | - (URLEditor *)appendLinkWithText:(NSString *)linkText linkFont:(UIFont *)linkFont linkColor:(UIColor *)linkColor underLineStyle:(CTUnderlineStyle)underLineStyle linkData:(id)linkData; 94 | 95 | #pragma mark - Container 96 | - (void)addContainer:(BaseContainer *)container; 97 | - (void)appendContainer:(BaseContainer *)container; 98 | 99 | #pragma mark - UIView扩展 100 | - (ViewContainer *)insertView:(UIView *)view range:(NSRange)range edge:(UIEdgeInsets)edge alignment:(ContainerAlignment)alignment; 101 | - (ViewContainer *)appendView:(UIView *)view edge:(UIEdgeInsets)edge alignment:(ContainerAlignment)alignment; 102 | 103 | #pragma mark - 图片扩展 104 | - (ImageContainer *)insertImage:(UIImage *)image range:(NSRange)range size:(CGSize)size edge:(UIEdgeInsets)edge; 105 | - (ImageContainer *)appendImage:(UIImage *)image size:(CGSize)size edge:(UIEdgeInsets)edge; 106 | 107 | - (ImageContainer *)insertImageWithName:(NSString *)imageName range:(NSRange)range size:(CGSize)size edge:(UIEdgeInsets)edge; 108 | - (ImageContainer *)appendImageWithName:(NSString *)imageName size:(CGSize)size edge:(UIEdgeInsets)edge; 109 | 110 | - (ImageContainer *)insertImageWithURLString:(NSString *)urlstring placeholdImageName:(NSString *)placeholdImageName range:(NSRange)range size:(CGSize)size edge:(UIEdgeInsets)edge; 111 | - (ImageContainer *)appendImageWithURLString:(NSString *)urlstring placeholdImageName:(NSString *)placeholdImageName size:(CGSize)size edge:(UIEdgeInsets)edge; 112 | 113 | #pragma mark - 获取高度 114 | - (CGFloat)getHeightWithWidth:(CGFloat)width; 115 | - (CTFrameCreator *)getCTFrameCreatorWithSize:(CGSize)size; 116 | 117 | - (void)disableSelectStatus; 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /CTUnlimitedView/BaseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.m 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/1/11. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | #import "QQViewController.h" 12 | #import "AutolayoutViewController.h" 13 | #import "TextAroundImagesViewController.h" 14 | #import "FPSViewController.h" 15 | 16 | #import "CustomHUD.h" 17 | 18 | @interface BaseViewController () 19 | 20 | @property (nonatomic, strong) UITableView *tableView; 21 | 22 | @property (nonatomic, strong) NSArray *titleArray; 23 | 24 | @end 25 | 26 | @implementation BaseViewController 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | 31 | self.view.backgroundColor = [UIColor whiteColor]; 32 | self.navigationItem.title = @"图文处理"; 33 | 34 | self.titleArray = @[@"图文混排", @"autolayout", @"图片高度自适应", @"文字环绕图片", @"帧数测试", @"清除图片"]; 35 | [self createTableView]; 36 | // Do any additional setup after loading the view. 37 | } 38 | 39 | - (void)createTableView { 40 | self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 41 | self.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)); 42 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"]; 43 | self.tableView.delegate = self; 44 | self.tableView.dataSource = self; 45 | self.tableView.tableFooterView = [UIView new]; 46 | [self.view addSubview:_tableView]; 47 | } 48 | 49 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 50 | return self.titleArray.count; 51 | } 52 | 53 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 54 | return 60; 55 | } 56 | 57 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 58 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 59 | 60 | cell.textLabel.text = self.titleArray[indexPath.row]; 61 | cell.textLabel.textColor = [UIColor lightGrayColor]; 62 | cell.textLabel.font = [UIFont systemFontOfSize:15]; 63 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 64 | return cell; 65 | } 66 | 67 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 68 | if (indexPath.row == 0) { 69 | 70 | NSInteger type = arc4random() % 11; 71 | if (type == 0) { 72 | [CustomHUD showWithStatus:@"活该你就高考啦啦啦啦开始实施"]; 73 | } else if (type == 1) { 74 | [CustomHUD showError]; 75 | } else if (type == 2) { 76 | [CustomHUD showErrorWithStatus:@"即打算减肥拉萨"]; 77 | } else if (type == 3) { 78 | [CustomHUD showSuccess]; 79 | } else if (type == 4) { 80 | [CustomHUD showSuccessWithStatus:@"将诶感觉你来到"]; 81 | } else if (type == 5) { 82 | [CustomHUD showProgress]; 83 | } else if (type == 6) { 84 | [CustomHUD showProgressWithStatus:@"fjishnvglisjgmo;xf"]; 85 | } else if (type == 7) { 86 | [CustomHUD showIndicator]; 87 | } else if (type == 8) { 88 | [CustomHUD showIndicatorWithStatus:@"fjidsahgnlfajgo"]; 89 | } else if (type == 9) { 90 | [CustomHUD showPhysicsProgress]; 91 | } else if (type == 10) { 92 | [CustomHUD showPhysicsProgressWithStatus:@"埃及个 i 哦桑来到纪念馆 i 拍电视剧那个可怜的娃看见阿MSN看"]; 93 | } 94 | 95 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 96 | [CustomHUD dismiss]; 97 | }); 98 | self.titleArray = @[@"图文混排", @"autolayout", @"图片高度自适应", @"文字环绕图片", @"帧数测试", @"清除图片"]; 99 | QQViewController *qq = [[QQViewController alloc] init]; 100 | [self.navigationController pushViewController:qq animated:YES]; 101 | } else if (indexPath.row == 1) { 102 | AutolayoutViewController *autolayoutvc = [[AutolayoutViewController alloc] init]; 103 | [self.navigationController pushViewController:autolayoutvc animated:YES]; 104 | } else if (indexPath.row == 2) { 105 | 106 | } else if (indexPath.row == 3) { 107 | TextAroundImagesViewController *textaroundimagesvc = [[TextAroundImagesViewController alloc] init]; 108 | [self.navigationController pushViewController:textaroundimagesvc animated:YES]; 109 | } else if (indexPath.row == 4) { 110 | FPSViewController *fpsvc = [[FPSViewController alloc] init]; 111 | [self.navigationController pushViewController:fpsvc animated:YES]; 112 | } else { 113 | } 114 | } 115 | 116 | - (void)didReceiveMemoryWarning { 117 | [super didReceiveMemoryWarning]; 118 | // Dispose of any resources that can be recreated. 119 | } 120 | 121 | /* 122 | #pragma mark - Navigation 123 | 124 | // In a storyboard-based application, you will often want to do a little preparation before navigation 125 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 126 | // Get the new view controller using [segue destinationViewController]. 127 | // Pass the selected object to the new view controller. 128 | } 129 | */ 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 || TARGET_OS_TV) 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 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if TARGET_OS_IPHONE || TARGET_OS_TV 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if TARGET_OS_IPHONE || TARGET_OS_TV 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstrait are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if TARGET_OS_IPHONE || TARGET_OS_TV 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #pragma mark - associated properties 138 | 139 | - (id)mas_key { 140 | return objc_getAssociatedObject(self, @selector(mas_key)); 141 | } 142 | 143 | - (void)setMas_key:(id)key { 144 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 145 | } 146 | 147 | #pragma mark - heirachy 148 | 149 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 150 | MAS_VIEW *closestCommonSuperview = nil; 151 | 152 | MAS_VIEW *secondViewSuperview = view; 153 | while (!closestCommonSuperview && secondViewSuperview) { 154 | MAS_VIEW *firstViewSuperview = self; 155 | while (!closestCommonSuperview && firstViewSuperview) { 156 | if (secondViewSuperview == firstViewSuperview) { 157 | closestCommonSuperview = secondViewSuperview; 158 | } 159 | firstViewSuperview = firstViewSuperview.superview; 160 | } 161 | secondViewSuperview = secondViewSuperview.superview; 162 | } 163 | return closestCommonSuperview; 164 | } 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.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 "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if TARGET_OS_IPHONE || TARGET_OS_TV 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | if (prev) { 103 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 104 | make.width.equalTo(@(fixedItemLength)); 105 | if (i == self.count - 1) {//last one 106 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 107 | } 108 | else { 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | make.width.equalTo(@(fixedItemLength)); 115 | } 116 | }]; 117 | prev = v; 118 | } 119 | } 120 | else { 121 | MAS_VIEW *prev; 122 | for (int i = 0; i < self.count; i++) { 123 | MAS_VIEW *v = self[i]; 124 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 125 | if (prev) { 126 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 127 | make.height.equalTo(@(fixedItemLength)); 128 | if (i == self.count - 1) {//last one 129 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 130 | } 131 | else { 132 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 133 | } 134 | } 135 | else {//first one 136 | make.top.equalTo(tempSuperView).offset(leadSpacing); 137 | make.height.equalTo(@(fixedItemLength)); 138 | } 139 | }]; 140 | prev = v; 141 | } 142 | } 143 | } 144 | 145 | - (MAS_VIEW *)mas_commonSuperviewOfViews 146 | { 147 | MAS_VIEW *commonSuperview = nil; 148 | MAS_VIEW *previousView = nil; 149 | for (id object in self) { 150 | if ([object isKindOfClass:[MAS_VIEW class]]) { 151 | MAS_VIEW *view = (MAS_VIEW *)object; 152 | if (previousView) { 153 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 154 | } else { 155 | commonSuperview = view; 156 | } 157 | previousView = view; 158 | } 159 | } 160 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 161 | return commonSuperview; 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /CTUnlimitedView/CTUnlimitedView.framework/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | .DS_Store 8 | 9 | n8b5ZnR3gPOBT0Vfhpk9cuWLerk= 10 | 11 | Headers/BaseContainer.h 12 | 13 | 1Qcyv9hFRLVxgWtgysot7gO8snU= 14 | 15 | Headers/CTFrameCreator.h 16 | 17 | 2TOZRyeljS1cpcOcRrmf4kpJV5Y= 18 | 19 | Headers/CTUnlimitedView.h 20 | 21 | ILAun2QTUqT5fswKk5hKHuJWRz4= 22 | 23 | Headers/ImageContainer.h 24 | 25 | yUJJsDarSFn1M8jYU0+oHI+Dy18= 26 | 27 | Headers/NSMutableAttributedString+CoreTextMethod.h 28 | 29 | 6kTyZczphdy9dwyLh/5NVoARh2g= 30 | 31 | Headers/RichTextProtocol.h 32 | 33 | 79pvBiD6kIdJKfOT14NnoT5jkxQ= 34 | 35 | Headers/TextEditor.h 36 | 37 | wtdGwQYy41yuIv3THvn+5sKurYY= 38 | 39 | Headers/URLEditor.h 40 | 41 | rxUvG80B+3WGvNONI6MkGW6vVio= 42 | 43 | Headers/UUImageCache.h 44 | 45 | Eq9FsBOAVJHDgZ4jQuIxu/XmcwM= 46 | 47 | Headers/ViewContainer.h 48 | 49 | kWLh2OgIydFUpEUo+n4fzzxJrA4= 50 | 51 | Info.plist 52 | 53 | IbE0p4luHGmC22exQUfsOdWAlks= 54 | 55 | Modules/module.modulemap 56 | 57 | RTHRULPZ1DLqYTt7vo1rpECtDfc= 58 | 59 | 60 | files2 61 | 62 | Headers/BaseContainer.h 63 | 64 | hash 65 | 66 | 1Qcyv9hFRLVxgWtgysot7gO8snU= 67 | 68 | hash2 69 | 70 | BhehPIvzB4qlmfocTr8uaeEPEwapRj6FZ0nk0nYQv+g= 71 | 72 | 73 | Headers/CTFrameCreator.h 74 | 75 | hash 76 | 77 | 2TOZRyeljS1cpcOcRrmf4kpJV5Y= 78 | 79 | hash2 80 | 81 | mjUM+TaUipbreVdWSq+Bs3IU0lwxFlQvPfJ+WTiv5+I= 82 | 83 | 84 | Headers/CTUnlimitedView.h 85 | 86 | hash 87 | 88 | ILAun2QTUqT5fswKk5hKHuJWRz4= 89 | 90 | hash2 91 | 92 | GkQ6yNTId5kxpXHcYXJvptRX2b0nnX1/E844ELOZTSw= 93 | 94 | 95 | Headers/ImageContainer.h 96 | 97 | hash 98 | 99 | yUJJsDarSFn1M8jYU0+oHI+Dy18= 100 | 101 | hash2 102 | 103 | qQ59DlmmDubjbrP+VAXw/J3RluWTvjfrWWS/T8GG+RI= 104 | 105 | 106 | Headers/NSMutableAttributedString+CoreTextMethod.h 107 | 108 | hash 109 | 110 | 6kTyZczphdy9dwyLh/5NVoARh2g= 111 | 112 | hash2 113 | 114 | Xb7gnQHrQRac7F66H8WiLaOmshgHD96hMBiviWI17j8= 115 | 116 | 117 | Headers/RichTextProtocol.h 118 | 119 | hash 120 | 121 | 79pvBiD6kIdJKfOT14NnoT5jkxQ= 122 | 123 | hash2 124 | 125 | OahYx7sFtLBvjXUc/AoEns31+U2xQ4okPC65GOtZe2I= 126 | 127 | 128 | Headers/TextEditor.h 129 | 130 | hash 131 | 132 | wtdGwQYy41yuIv3THvn+5sKurYY= 133 | 134 | hash2 135 | 136 | oFqMfpcP5P+SB2eIcajGdh+Br198fgteqzPkDbrvuBE= 137 | 138 | 139 | Headers/URLEditor.h 140 | 141 | hash 142 | 143 | rxUvG80B+3WGvNONI6MkGW6vVio= 144 | 145 | hash2 146 | 147 | TSAQzDNYtb52ABmnlPe1FxOe6NmCGM+2YVvw3Vnqj+s= 148 | 149 | 150 | Headers/UUImageCache.h 151 | 152 | hash 153 | 154 | Eq9FsBOAVJHDgZ4jQuIxu/XmcwM= 155 | 156 | hash2 157 | 158 | 3Ub8BqaKLqaMvcP2sRMmIzPSYUy4vagLfciQ3e3d5gQ= 159 | 160 | 161 | Headers/ViewContainer.h 162 | 163 | hash 164 | 165 | kWLh2OgIydFUpEUo+n4fzzxJrA4= 166 | 167 | hash2 168 | 169 | o4/gcgEw2H3Whi3U76j2mqoUMTr5wAGnG+COdi/97Mk= 170 | 171 | 172 | Modules/module.modulemap 173 | 174 | hash 175 | 176 | RTHRULPZ1DLqYTt7vo1rpECtDfc= 177 | 178 | hash2 179 | 180 | gKyIMlvsNwIIMKpyc3gN1OyUyOJNbUXvBrg+RYPb7zs= 181 | 182 | 183 | 184 | rules 185 | 186 | ^ 187 | 188 | ^.*\.lproj/ 189 | 190 | optional 191 | 192 | weight 193 | 1000 194 | 195 | ^.*\.lproj/locversion.plist$ 196 | 197 | omit 198 | 199 | weight 200 | 1100 201 | 202 | ^Base\.lproj/ 203 | 204 | weight 205 | 1010 206 | 207 | ^version.plist$ 208 | 209 | 210 | rules2 211 | 212 | .*\.dSYM($|/) 213 | 214 | weight 215 | 11 216 | 217 | ^ 218 | 219 | weight 220 | 20 221 | 222 | ^(.*/)?\.DS_Store$ 223 | 224 | omit 225 | 226 | weight 227 | 2000 228 | 229 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 230 | 231 | nested 232 | 233 | weight 234 | 10 235 | 236 | ^.* 237 | 238 | ^.*\.lproj/ 239 | 240 | optional 241 | 242 | weight 243 | 1000 244 | 245 | ^.*\.lproj/locversion.plist$ 246 | 247 | omit 248 | 249 | weight 250 | 1100 251 | 252 | ^Base\.lproj/ 253 | 254 | weight 255 | 1010 256 | 257 | ^Info\.plist$ 258 | 259 | omit 260 | 261 | weight 262 | 20 263 | 264 | ^PkgInfo$ 265 | 266 | omit 267 | 268 | weight 269 | 20 270 | 271 | ^[^/]+$ 272 | 273 | nested 274 | 275 | weight 276 | 10 277 | 278 | ^embedded\.provisionprofile$ 279 | 280 | weight 281 | 20 282 | 283 | ^version\.plist$ 284 | 285 | weight 286 | 20 287 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 131 | 132 | - (MASConstraint *)firstBaseline; 133 | - (MASConstraint *)lastBaseline; 134 | 135 | #endif 136 | 137 | #if TARGET_OS_IPHONE || TARGET_OS_TV 138 | 139 | - (MASConstraint *)leftMargin; 140 | - (MASConstraint *)rightMargin; 141 | - (MASConstraint *)topMargin; 142 | - (MASConstraint *)bottomMargin; 143 | - (MASConstraint *)leadingMargin; 144 | - (MASConstraint *)trailingMargin; 145 | - (MASConstraint *)centerXWithinMargins; 146 | - (MASConstraint *)centerYWithinMargins; 147 | 148 | #endif 149 | 150 | 151 | /** 152 | * Sets the constraint debug name 153 | */ 154 | - (MASConstraint * (^)(id key))key; 155 | 156 | // NSLayoutConstraint constant Setters 157 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 163 | */ 164 | - (void)setInsets:(MASEdgeInsets)insets; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 170 | */ 171 | - (void)setSizeOffset:(CGSize)sizeOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 177 | */ 178 | - (void)setCenterOffset:(CGPoint)centerOffset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant 182 | */ 183 | - (void)setOffset:(CGFloat)offset; 184 | 185 | 186 | // NSLayoutConstraint Installation support 187 | 188 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 189 | /** 190 | * Whether or not to go through the animator proxy when modifying the constraint 191 | */ 192 | @property (nonatomic, copy, readonly) MASConstraint *animator; 193 | #endif 194 | 195 | /** 196 | * Activates an NSLayoutConstraint if it's supported by an OS. 197 | * Invokes install otherwise. 198 | */ 199 | - (void)activate; 200 | 201 | /** 202 | * Deactivates previously installed/activated NSLayoutConstraint. 203 | */ 204 | - (void)deactivate; 205 | 206 | /** 207 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 208 | */ 209 | - (void)install; 210 | 211 | /** 212 | * Removes previously installed NSLayoutConstraint 213 | */ 214 | - (void)uninstall; 215 | 216 | @end 217 | 218 | 219 | /** 220 | * Convenience auto-boxing macros for MASConstraint methods. 221 | * 222 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 223 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 224 | */ 225 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 226 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 227 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 228 | 229 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 230 | 231 | 232 | #ifdef MAS_SHORTHAND_GLOBALS 233 | 234 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 235 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 236 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 237 | 238 | #define offset(...) mas_offset(__VA_ARGS__) 239 | 240 | #endif 241 | 242 | 243 | @interface MASConstraint (AutoboxingSupport) 244 | 245 | /** 246 | * Aliases to corresponding relation methods (for shorthand macros) 247 | * Also needed to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id attr))mas_equalTo; 250 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 251 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 252 | 253 | /** 254 | * A dummy method to aid autocompletion 255 | */ 256 | - (MASConstraint * (^)(id offset))mas_offset; 257 | 258 | @end 259 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 212 | 213 | - (MASConstraint *)firstBaseline { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 215 | } 216 | - (MASConstraint *)lastBaseline { 217 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 218 | } 219 | 220 | #endif 221 | 222 | #if TARGET_OS_IPHONE || TARGET_OS_TV 223 | 224 | - (MASConstraint *)leftMargin { 225 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 226 | } 227 | 228 | - (MASConstraint *)rightMargin { 229 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 230 | } 231 | 232 | - (MASConstraint *)topMargin { 233 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 234 | } 235 | 236 | - (MASConstraint *)bottomMargin { 237 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 238 | } 239 | 240 | - (MASConstraint *)leadingMargin { 241 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 242 | } 243 | 244 | - (MASConstraint *)trailingMargin { 245 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 246 | } 247 | 248 | - (MASConstraint *)centerXWithinMargins { 249 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 250 | } 251 | 252 | - (MASConstraint *)centerYWithinMargins { 253 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 254 | } 255 | 256 | #endif 257 | 258 | #pragma mark - Abstract 259 | 260 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 261 | 262 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 263 | 264 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 265 | 266 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 267 | 268 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 269 | 270 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 271 | 272 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 273 | 274 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 275 | 276 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 277 | 278 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 279 | 280 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 281 | 282 | #endif 283 | 284 | - (void)activate { MASMethodNotImplemented(); } 285 | 286 | - (void)deactivate { MASMethodNotImplemented(); } 287 | 288 | - (void)install { MASMethodNotImplemented(); } 289 | 290 | - (void)uninstall { MASMethodNotImplemented(); } 291 | 292 | @end 293 | -------------------------------------------------------------------------------- /CTUnlimitedView/RichText/QQTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // QQTableViewCell.m 3 | // CTUnlimitedView 4 | // 5 | // Created by 酌晨茗 on 16/2/18. 6 | // Copyright © 2016年 酌晨茗. All rights reserved. 7 | // 8 | 9 | #import "QQTableViewCell.h" 10 | 11 | @implementation QQTableViewCell 12 | 13 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 14 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 15 | if (self) { 16 | // self.backgroundColor = [UIColor colorWithRed:244 / 255.0 green:244 / 255.0 blue:244 / 255.0 alpha:1.0]; 17 | self.backgroundColor = [UIColor whiteColor]; 18 | self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 30, 30)]; 19 | [self addSubview:_headImgView]; 20 | 21 | self.nameLable = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, 200, 30)]; 22 | [self addSubview:_nameLable]; 23 | 24 | self.attriLable = [[CTUnlimitedView alloc] init]; 25 | self.attriLable.backgroundColor = self.backgroundColor; 26 | self.attriLable.drawType = DrawTextAndPicture; 27 | 28 | self.attriLable.frame = CGRectMake(15, CGRectGetMaxY(self.headImgView.frame) + 10, CGRectGetWidth([UIScreen mainScreen].bounds) - 30, 0); 29 | // self.attriLable.isCopyAvailable = NO; 30 | [self addSubview:_attriLable]; 31 | 32 | self.shareButton = [self customButtonWithTitle:@"分享"]; 33 | [self addSubview:_shareButton]; 34 | 35 | self.supportButton = [self customButtonWithTitle:@"赞"]; 36 | [self addSubview:_supportButton]; 37 | 38 | self.commentButton = [self customButtonWithTitle:@"评论"]; 39 | [self addSubview:_commentButton]; 40 | 41 | self.commentLable = [[CTUnlimitedView alloc] init]; 42 | self.commentLable.backgroundColor = self.backgroundColor; 43 | self.commentLable.drawType = DrawTextAndPicture; 44 | [self addSubview:_commentLable]; 45 | } 46 | return self; 47 | } 48 | 49 | - (UIButton *)customButtonWithTitle:(NSString *)title { 50 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 51 | [button setTitle:title forState:UIControlStateNormal]; 52 | [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 53 | button.titleLabel.font = [UIFont systemFontOfSize:11]; 54 | button.layer.borderColor = [UIColor lightGrayColor].CGColor; 55 | button.layer.borderWidth = 0.5; 56 | button.layer.cornerRadius = 5.0; 57 | return button; 58 | } 59 | 60 | - (void)setModel:(QQRoomModel *)model { 61 | _model = model; 62 | [self setContenString:model.title imageNameArray:model.imgNameArray urlString:model.imgURLArray[0] commentArray:model.commentArray]; 63 | } 64 | 65 | - (void)setContenString:(NSString *)contenString imageNameArray:(NSArray *)imageNameArray urlString:(NSString *)urlstring commentArray:(NSArray *)commentArray { 66 | //1.先处理纯文本 67 | NSMutableAttributedString *atr = [[NSMutableAttributedString alloc] initWithString:contenString]; 68 | [atr textColor:[UIColor lightGrayColor]]; 69 | [atr font:[UIFont systemFontOfSize:16]]; 70 | [atr textColor:[UIColor redColor]]; 71 | self.attriLable.attributedText = atr; 72 | 73 | self.attriLable.linesSpacing = 10; 74 | self.attriLable.textColor = [UIColor lightGrayColor]; 75 | 76 | TextEditor *textEditor = [TextEditor new]; 77 | textEditor.text = @"@盗版:坐等你的打脸大招"; 78 | textEditor.range = NSMakeRange(11, 0); 79 | textEditor.textColor = [UIColor purpleColor]; 80 | textEditor.underLineStyle = kCTUnderlineStyleSingle; 81 | [self.attriLable addTextEditor:textEditor]; 82 | 83 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"就喜欢你看不惯我又干不掉我的样子,显得呆萌呆萌哒\n"]; 84 | [attString alignmentStyle:kCTTextAlignmentCenter lineSpaceStyle:10 paragraphSpaceStyle:10 lineBreakStyle:kCTLineBreakByClipping]; 85 | 86 | [self.attriLable appendAttributedString:attString]; 87 | 88 | 89 | //2.处理链接 90 | [self.attriLable insertLinkWithLinkData:@"" linkColor:[UIColor greenColor] underLineStyle:kCTUnderlineStyleSingle range:NSMakeRange(5, 5)]; 91 | [self.attriLable appendText:@"\n"]; 92 | [self.attriLable appendLinkWithText:@"@可怜的小八" linkFont:[UIFont systemFontOfSize:14] linkColor:[UIColor orangeColor] underLineStyle:kCTUnderlineStyleSingle linkData:@""]; 93 | [self.attriLable appendText:@":你丫的\n"]; 94 | //3.处理container 95 | 96 | UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)]; 97 | lable.text = @"你是逗比"; 98 | [self.attriLable insertView:lable range:NSMakeRange(3, 0) edge:UIEdgeInsetsZero alignment:ContainerAlignmentCenter]; 99 | 100 | 101 | CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds); 102 | 103 | NSInteger attLength = _attriLable.text.length; 104 | CGFloat width = (screenWidth - 50) / 3.0; 105 | 106 | for (int i = 0; i < imageNameArray.count; i++) { 107 | UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, width)]; 108 | imgView.image = [UIImage imageNamed:imageNameArray[i]]; 109 | // imgView.backgroundColor = [UIColor redColor]; 110 | [self.attriLable insertView:imgView range:NSMakeRange(attLength + i, 0) edge:UIEdgeInsetsMake(3, 0, 3, 3) alignment:ContainerAlignmentCenter]; 111 | } 112 | 113 | // for (int i = 0; i < imageNameArray.count; i++) { 114 | //// if (i == 2 || i == 5 || i == 8 || i == 11) { 115 | //// [self.attriLable insertImageWithName:imageNameArray[i] range:NSMakeRange(contenString.length + 10 + i, 0) size:CGSizeMake(width, width) edge:UIEdgeInsetsMake(10, 0, 10, 0)]; 116 | //// } else { 117 | //// 118 | //// } 119 | // ImageContainer *imageContainer = [self.attriLable insertImageWithName:imageNameArray[i] range:NSMakeRange(attLength + i, 0) size:CGSizeMake(width, width) edge:UIEdgeInsetsMake(3, 0, 3, 3)]; 120 | // imageContainer.tag = 3000 + i; 121 | // } 122 | // 123 | // NSArray *tagArray = @[@(3002), @(3005), @(3008), @(3011)]; 124 | // for (int i = 0; i < tagArray.count; i++) { 125 | // ImageContainer *imageContainer = [self.attriLable richTextWithTag:[tagArray[i] integerValue]]; 126 | // imageContainer.edge = UIEdgeInsetsMake(3, 0, 3, 0); 127 | // } 128 | 129 | [self.attriLable appendText:@"\n呵呵哒"]; 130 | [self.attriLable appendAttributedString:[[NSAttributedString alloc] initWithString:@"貌似是拼接的"]]; 131 | 132 | // NSArray *imgURLStringArray = @[@"http://img.xiuren.com/taotu/355/samples_o/0011.jpg", @"http://img.xiuren.com/taotu/355/samples_o/0043.jpg", @"http://img.xiuren.com/taotu/355/samples_o/0064.jpg", @"http://img.xiuren.com/taotu/1/samples_o/0027.jpg", @"http://img.xiuren.com/taotu/1/samples_o/0044.jpg", @"http://img.xiuren.com/taotu/1/samples_o/0078.jpg", @"http://img.xiuren.com/taotu/1453/samples_o/0001.jpg", @"http://img.xiuren.com/taotu/1453/samples_o/0039.jpg", @"http://img.xiuren.com/taotu/1453/samples_o/0058.jpg"]; 133 | // for (int i = 0; i < imgURLStringArray.count; i++) { 134 | // [self.attriLable appendImageWithURLString:imgURLStringArray[i] placeholdImageName:@"" size:CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds) - 30, 500) edge:UIEdgeInsetsMake(10, 0, 10, 0)]; 135 | // } 136 | 137 | // [self.attriLable appendImageWithURLString:urlstring placeholdImageName:@"" size:CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds) - 30, 230) edge:UIEdgeInsetsMake(10, 0, 10, 0)]; 138 | 139 | // NSString *myImageURLString = @"http://img1.36706.com/lipic/allimg/201312/2-131226223645593.jpg"; 140 | // NSString *myImageURLString = @"http://imgsrc.baidu.com/forum/pic/item/43ddbcca39dbb6fde9461a5c0124ab18972b37b7.jpg"; 141 | // [self.attriLable appendImageWithURLString:myImageURLString placeholdImageName:@"" size:CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), 300) edge:UIEdgeInsetsZero]; 142 | // [self.attriLable appendAttributedString:[[NSAttributedString alloc] initWithString:@"貌似是拼接的"]]; 143 | // [self.attriLable appendLinkWithText:@"\n拼接的链接" linkFont:[UIFont systemFontOfSize:14] linkColor:[UIColor orangeColor] underLineStyle:kCTUnderlineStyleSingle linkData:@""]; 144 | [self commentLableWithArray:commentArray]; 145 | } 146 | 147 | - (void)setDataWithContainer:(CTFrameCreator *)container commentArray:(NSArray *)commentArray { 148 | self.attriLable.frameCreator = container; 149 | [self commentLableWithArray:commentArray]; 150 | } 151 | 152 | - (void)commentLableWithArray:(NSArray *)commintArray { 153 | NSMutableAttributedString *mAttString = [NSMutableAttributedString new]; 154 | for (int i = 0; i < commintArray.count; i++) { 155 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:commintArray[i]]; 156 | [attString alignmentStyle:kCTTextAlignmentLeft lineSpaceStyle:1 paragraphSpaceStyle:15 lineBreakStyle:kCTLineBreakByCharWrapping range:NSMakeRange(0, attString.length)]; 157 | [attString underlineColor:[UIColor redColor] range:NSMakeRange(0, 3)]; 158 | [attString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)]; 159 | [attString textColor:[UIColor lightGrayColor]]; 160 | [mAttString appendAttributedString:attString]; 161 | } 162 | self.commentLable.attributedText = mAttString; 163 | } 164 | 165 | - (void)awakeFromNib { 166 | // Initialization code 167 | } 168 | 169 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 170 | [super setSelected:selected animated:animated]; 171 | 172 | // Configure the view for the selected state 173 | } 174 | 175 | @end 176 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.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 "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 82 | | MASAttributeFirstBaseline | MASAttributeLastBaseline 83 | #endif 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 86 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 87 | | MASAttributeCenterYWithinMargins 88 | #endif 89 | ); 90 | 91 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 92 | 93 | NSMutableArray *attributes = [NSMutableArray array]; 94 | 95 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 96 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 97 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 98 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 99 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 100 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 101 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 102 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 103 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 104 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 105 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 106 | 107 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 108 | 109 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline]; 110 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline]; 111 | 112 | #endif 113 | 114 | #if TARGET_OS_IPHONE || TARGET_OS_TV 115 | 116 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 117 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 118 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 119 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 120 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 121 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 122 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 123 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 124 | 125 | #endif 126 | 127 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 128 | 129 | for (MASViewAttribute *a in attributes) { 130 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 131 | } 132 | 133 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 134 | constraint.delegate = self; 135 | [self.constraints addObject:constraint]; 136 | return constraint; 137 | } 138 | 139 | #pragma mark - standard Attributes 140 | 141 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 142 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 143 | } 144 | 145 | - (MASConstraint *)left { 146 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 147 | } 148 | 149 | - (MASConstraint *)top { 150 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 151 | } 152 | 153 | - (MASConstraint *)right { 154 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 155 | } 156 | 157 | - (MASConstraint *)bottom { 158 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 159 | } 160 | 161 | - (MASConstraint *)leading { 162 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 163 | } 164 | 165 | - (MASConstraint *)trailing { 166 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 167 | } 168 | 169 | - (MASConstraint *)width { 170 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 171 | } 172 | 173 | - (MASConstraint *)height { 174 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 175 | } 176 | 177 | - (MASConstraint *)centerX { 178 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 179 | } 180 | 181 | - (MASConstraint *)centerY { 182 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 183 | } 184 | 185 | - (MASConstraint *)baseline { 186 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 187 | } 188 | 189 | - (MASConstraint *(^)(MASAttribute))attributes { 190 | return ^(MASAttribute attrs){ 191 | return [self addConstraintWithAttributes:attrs]; 192 | }; 193 | } 194 | 195 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 196 | 197 | - (MASConstraint *)firstBaseline { 198 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 199 | } 200 | 201 | - (MASConstraint *)lastBaseline { 202 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 203 | } 204 | 205 | #endif 206 | 207 | 208 | #if TARGET_OS_IPHONE || TARGET_OS_TV 209 | 210 | - (MASConstraint *)leftMargin { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 212 | } 213 | 214 | - (MASConstraint *)rightMargin { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 216 | } 217 | 218 | - (MASConstraint *)topMargin { 219 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 220 | } 221 | 222 | - (MASConstraint *)bottomMargin { 223 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 224 | } 225 | 226 | - (MASConstraint *)leadingMargin { 227 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 228 | } 229 | 230 | - (MASConstraint *)trailingMargin { 231 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 232 | } 233 | 234 | - (MASConstraint *)centerXWithinMargins { 235 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 236 | } 237 | 238 | - (MASConstraint *)centerYWithinMargins { 239 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 240 | } 241 | 242 | #endif 243 | 244 | 245 | #pragma mark - composite Attributes 246 | 247 | - (MASConstraint *)edges { 248 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 249 | } 250 | 251 | - (MASConstraint *)size { 252 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 253 | } 254 | 255 | - (MASConstraint *)center { 256 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 257 | } 258 | 259 | #pragma mark - grouping 260 | 261 | - (MASConstraint *(^)(dispatch_block_t group))group { 262 | return ^id(dispatch_block_t group) { 263 | NSInteger previousCount = self.constraints.count; 264 | group(); 265 | 266 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 267 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 268 | constraint.delegate = self; 269 | return constraint; 270 | }; 271 | } 272 | 273 | @end 274 | -------------------------------------------------------------------------------- /CTUnlimitedView/Others/Masonry/MASViewConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.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 "MASViewConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASLayoutConstraint.h" 13 | #import "View+MASAdditions.h" 14 | #import 15 | 16 | @interface MAS_VIEW (MASConstraints) 17 | 18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints; 19 | 20 | @end 21 | 22 | @implementation MAS_VIEW (MASConstraints) 23 | 24 | static char kInstalledConstraintsKey; 25 | 26 | - (NSMutableSet *)mas_installedConstraints { 27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey); 28 | if (!constraints) { 29 | constraints = [NSMutableSet set]; 30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | } 32 | return constraints; 33 | } 34 | 35 | @end 36 | 37 | 38 | @interface MASViewConstraint () 39 | 40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute; 41 | @property (nonatomic, weak) MAS_VIEW *installedView; 42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint; 43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation; 44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority; 45 | @property (nonatomic, assign) CGFloat layoutMultiplier; 46 | @property (nonatomic, assign) CGFloat layoutConstant; 47 | @property (nonatomic, assign) BOOL hasLayoutRelation; 48 | @property (nonatomic, strong) id mas_key; 49 | @property (nonatomic, assign) BOOL useAnimator; 50 | 51 | @end 52 | 53 | @implementation MASViewConstraint 54 | 55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { 56 | self = [super init]; 57 | if (!self) return nil; 58 | 59 | _firstViewAttribute = firstViewAttribute; 60 | self.layoutPriority = MASLayoutPriorityRequired; 61 | self.layoutMultiplier = 1; 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - NSCoping 67 | 68 | - (id)copyWithZone:(NSZone __unused *)zone { 69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; 70 | constraint.layoutConstant = self.layoutConstant; 71 | constraint.layoutRelation = self.layoutRelation; 72 | constraint.layoutPriority = self.layoutPriority; 73 | constraint.layoutMultiplier = self.layoutMultiplier; 74 | constraint.delegate = self.delegate; 75 | return constraint; 76 | } 77 | 78 | #pragma mark - Public 79 | 80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view { 81 | return [view.mas_installedConstraints allObjects]; 82 | } 83 | 84 | #pragma mark - Private 85 | 86 | - (void)setLayoutConstant:(CGFloat)layoutConstant { 87 | _layoutConstant = layoutConstant; 88 | 89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 90 | if (self.useAnimator) { 91 | [self.layoutConstraint.animator setConstant:layoutConstant]; 92 | } else { 93 | self.layoutConstraint.constant = layoutConstant; 94 | } 95 | #else 96 | self.layoutConstraint.constant = layoutConstant; 97 | #endif 98 | } 99 | 100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 101 | _layoutRelation = layoutRelation; 102 | self.hasLayoutRelation = YES; 103 | } 104 | 105 | - (BOOL)supportsActiveProperty { 106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)]; 107 | } 108 | 109 | - (BOOL)isActive { 110 | BOOL active = YES; 111 | if ([self supportsActiveProperty]) { 112 | active = [self.layoutConstraint isActive]; 113 | } 114 | 115 | return active; 116 | } 117 | 118 | - (BOOL)hasBeenInstalled { 119 | return (self.layoutConstraint != nil) && [self isActive]; 120 | } 121 | 122 | - (void)setSecondViewAttribute:(id)secondViewAttribute { 123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) { 124 | [self setLayoutConstantWithValue:secondViewAttribute]; 125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 128 | _secondViewAttribute = secondViewAttribute; 129 | } else { 130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 131 | } 132 | } 133 | 134 | #pragma mark - NSLayoutConstraint multiplier proxies 135 | 136 | - (MASConstraint * (^)(CGFloat))multipliedBy { 137 | return ^id(CGFloat multiplier) { 138 | NSAssert(!self.hasBeenInstalled, 139 | @"Cannot modify constraint multiplier after it has been installed"); 140 | 141 | self.layoutMultiplier = multiplier; 142 | return self; 143 | }; 144 | } 145 | 146 | 147 | - (MASConstraint * (^)(CGFloat))dividedBy { 148 | return ^id(CGFloat divider) { 149 | NSAssert(!self.hasBeenInstalled, 150 | @"Cannot modify constraint multiplier after it has been installed"); 151 | 152 | self.layoutMultiplier = 1.0/divider; 153 | return self; 154 | }; 155 | } 156 | 157 | #pragma mark - MASLayoutPriority proxy 158 | 159 | - (MASConstraint * (^)(MASLayoutPriority))priority { 160 | return ^id(MASLayoutPriority priority) { 161 | NSAssert(!self.hasBeenInstalled, 162 | @"Cannot modify constraint priority after it has been installed"); 163 | 164 | self.layoutPriority = priority; 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - NSLayoutRelation proxy 170 | 171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 172 | return ^id(id attribute, NSLayoutRelation relation) { 173 | if ([attribute isKindOfClass:NSArray.class]) { 174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 175 | NSMutableArray *children = NSMutableArray.new; 176 | for (id attr in attribute) { 177 | MASViewConstraint *viewConstraint = [self copy]; 178 | viewConstraint.secondViewAttribute = attr; 179 | [children addObject:viewConstraint]; 180 | } 181 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 182 | compositeConstraint.delegate = self.delegate; 183 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 184 | return compositeConstraint; 185 | } else { 186 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 187 | self.layoutRelation = relation; 188 | self.secondViewAttribute = attribute; 189 | return self; 190 | } 191 | }; 192 | } 193 | 194 | #pragma mark - Semantic properties 195 | 196 | - (MASConstraint *)with { 197 | return self; 198 | } 199 | 200 | - (MASConstraint *)and { 201 | return self; 202 | } 203 | 204 | #pragma mark - attribute chaining 205 | 206 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 207 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 208 | 209 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 210 | } 211 | 212 | #pragma mark - Animator proxy 213 | 214 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 215 | 216 | - (MASConstraint *)animator { 217 | self.useAnimator = YES; 218 | return self; 219 | } 220 | 221 | #endif 222 | 223 | #pragma mark - debug helpers 224 | 225 | - (MASConstraint * (^)(id))key { 226 | return ^id(id key) { 227 | self.mas_key = key; 228 | return self; 229 | }; 230 | } 231 | 232 | #pragma mark - NSLayoutConstraint constant setters 233 | 234 | - (void)setInsets:(MASEdgeInsets)insets { 235 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 236 | switch (layoutAttribute) { 237 | case NSLayoutAttributeLeft: 238 | case NSLayoutAttributeLeading: 239 | self.layoutConstant = insets.left; 240 | break; 241 | case NSLayoutAttributeTop: 242 | self.layoutConstant = insets.top; 243 | break; 244 | case NSLayoutAttributeBottom: 245 | self.layoutConstant = -insets.bottom; 246 | break; 247 | case NSLayoutAttributeRight: 248 | case NSLayoutAttributeTrailing: 249 | self.layoutConstant = -insets.right; 250 | break; 251 | default: 252 | break; 253 | } 254 | } 255 | 256 | - (void)setOffset:(CGFloat)offset { 257 | self.layoutConstant = offset; 258 | } 259 | 260 | - (void)setSizeOffset:(CGSize)sizeOffset { 261 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 262 | switch (layoutAttribute) { 263 | case NSLayoutAttributeWidth: 264 | self.layoutConstant = sizeOffset.width; 265 | break; 266 | case NSLayoutAttributeHeight: 267 | self.layoutConstant = sizeOffset.height; 268 | break; 269 | default: 270 | break; 271 | } 272 | } 273 | 274 | - (void)setCenterOffset:(CGPoint)centerOffset { 275 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 276 | switch (layoutAttribute) { 277 | case NSLayoutAttributeCenterX: 278 | self.layoutConstant = centerOffset.x; 279 | break; 280 | case NSLayoutAttributeCenterY: 281 | self.layoutConstant = centerOffset.y; 282 | break; 283 | default: 284 | break; 285 | } 286 | } 287 | 288 | #pragma mark - MASConstraint 289 | 290 | - (void)activate { 291 | [self install]; 292 | } 293 | 294 | - (void)deactivate { 295 | [self uninstall]; 296 | } 297 | 298 | - (void)install { 299 | if (self.hasBeenInstalled) { 300 | return; 301 | } 302 | 303 | if ([self supportsActiveProperty] && self.layoutConstraint) { 304 | self.layoutConstraint.active = YES; 305 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 306 | return; 307 | } 308 | 309 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item; 310 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 311 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item; 312 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 313 | 314 | // alignment attributes must have a secondViewAttribute 315 | // therefore we assume that is refering to superview 316 | // eg make.left.equalTo(@10) 317 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 318 | secondLayoutItem = self.firstViewAttribute.view.superview; 319 | secondLayoutAttribute = firstLayoutAttribute; 320 | } 321 | 322 | MASLayoutConstraint *layoutConstraint 323 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 324 | attribute:firstLayoutAttribute 325 | relatedBy:self.layoutRelation 326 | toItem:secondLayoutItem 327 | attribute:secondLayoutAttribute 328 | multiplier:self.layoutMultiplier 329 | constant:self.layoutConstant]; 330 | 331 | layoutConstraint.priority = self.layoutPriority; 332 | layoutConstraint.mas_key = self.mas_key; 333 | 334 | if (self.secondViewAttribute.view) { 335 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view]; 336 | NSAssert(closestCommonSuperview, 337 | @"couldn't find a common superview for %@ and %@", 338 | self.firstViewAttribute.view, self.secondViewAttribute.view); 339 | self.installedView = closestCommonSuperview; 340 | } else if (self.firstViewAttribute.isSizeAttribute) { 341 | self.installedView = self.firstViewAttribute.view; 342 | } else { 343 | self.installedView = self.firstViewAttribute.view.superview; 344 | } 345 | 346 | 347 | MASLayoutConstraint *existingConstraint = nil; 348 | if (self.updateExisting) { 349 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 350 | } 351 | if (existingConstraint) { 352 | // just update the constant 353 | existingConstraint.constant = layoutConstraint.constant; 354 | self.layoutConstraint = existingConstraint; 355 | } else { 356 | [self.installedView addConstraint:layoutConstraint]; 357 | self.layoutConstraint = layoutConstraint; 358 | [firstLayoutItem.mas_installedConstraints addObject:self]; 359 | } 360 | } 361 | 362 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 363 | // check if any constraints are the same apart from the only mutable property constant 364 | 365 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 366 | // and they are likely to be added first. 367 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 368 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 369 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 370 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 371 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 372 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 373 | if (existingConstraint.relation != layoutConstraint.relation) continue; 374 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 375 | if (existingConstraint.priority != layoutConstraint.priority) continue; 376 | 377 | return (id)existingConstraint; 378 | } 379 | return nil; 380 | } 381 | 382 | - (void)uninstall { 383 | if ([self supportsActiveProperty]) { 384 | self.layoutConstraint.active = NO; 385 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 386 | return; 387 | } 388 | 389 | [self.installedView removeConstraint:self.layoutConstraint]; 390 | self.layoutConstraint = nil; 391 | self.installedView = nil; 392 | 393 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 394 | } 395 | 396 | @end 397 | --------------------------------------------------------------------------------