├── 2223221.gif ├── UITableViewCell-展开查看更多 ├── Images.xcassets │ ├── 2245.imageset │ │ ├── 2245.png │ │ └── Contents.json │ ├── 4455.imageset │ │ ├── 4455.png │ │ └── Contents.json │ ├── 1123.imageset │ │ ├── 1123@2x.png │ │ └── Contents.json │ ├── IMG_0016.imageset │ │ ├── IMG_0016@2x.png │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── Classes │ ├── Controller │ │ ├── MainViewController.h │ │ └── MainViewController.m │ ├── Model │ │ ├── MCCommnetModel.m │ │ └── MCCommnetModel.h │ └── View │ │ ├── MCCommentCell.h │ │ └── MCCommentCell.m ├── lib │ └── Masonry │ │ ├── MASLayoutConstraint.m │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASCompositeConstraint.h │ │ ├── Masonry.h │ │ ├── Info.plist │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── MASViewConstraint.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASAdditions.h │ │ ├── MASConstraint+Private.h │ │ ├── View+MASShorthandAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── View+MASAdditions.m │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── MASUtilities.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.m │ │ └── MASViewConstraint.m ├── AppDelegate.h ├── main.m ├── AppDelegate.m ├── Common.h └── Info.plist ├── UITableViewCell-展开查看更多.xcodeproj ├── xcuserdata │ └── Ariel.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── UITableViewCell-展开查看更多.xcscheme ├── project.xcworkspace │ ├── xcuserdata │ │ └── Ariel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata └── project.pbxproj ├── README.md └── UITableViewCell-展开查看更多Tests ├── Info.plist └── UITableViewCell_______Tests.m /2223221.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/2223221.gif -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/2245.imageset/2245.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/UITableViewCell-展开查看更多/Images.xcassets/2245.imageset/2245.png -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/4455.imageset/4455.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/UITableViewCell-展开查看更多/Images.xcassets/4455.imageset/4455.png -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/1123.imageset/1123@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/UITableViewCell-展开查看更多/Images.xcassets/1123.imageset/1123@2x.png -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/IMG_0016.imageset/IMG_0016@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/UITableViewCell-展开查看更多/Images.xcassets/IMG_0016.imageset/IMG_0016@2x.png -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/xcuserdata/Ariel.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## UITableViewCell 展开查看更多 2 | * 由于朋友有需要、所以写的这个Demo 3 | * 不求 Star 4 | * 如有不足,请多提建议 5 | 6 | ## 说多都是废话,看图便知 7 | ![image](./2223221.gif) 8 | 9 | #### 联系方式
10 | Q Q:1363852560
11 | Mail:1363852560@qq.com
12 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/Controller/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface MainViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/project.xcworkspace/xcuserdata/Ariel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderXSLee/UITableViewCell/HEAD/UITableViewCell-展开查看更多.xcodeproj/project.xcworkspace/xcuserdata/Ariel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UITableViewCell-展开查看更多 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // Copyright (c) 2015年 Ariel. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UITableViewCell-展开查看更多 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // Copyright (c) 2015年 Ariel. 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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/Model/MCCommnetModel.m: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | 文件名称:MCCommnetModel.m 3 | 作 者:李雪松 4 | 备 注: 5 | 创建时间:15/5/22. 6 | 修改历史: 7 | 版权信息: Copyright (c) 2015年 Beijing Mooc Technology Center ltd. All rights reserved. 8 | ***************************************************************/ 9 | 10 | #import "MCCommnetModel.h" 11 | 12 | @implementation MCCommnetModel 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/2245.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "2245.png" 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 | } -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/4455.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "4455.png" 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 | } -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/1123.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "1123@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/IMG_0016.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "IMG_0016@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/xcuserdata/Ariel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | UITableViewCell-展开查看更多.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B0F829CB1B4CF8C3002A0A6F 16 | 17 | primary 18 | 19 | 20 | B0F829E71B4CF8C3002A0A6F 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UITableViewCell-展开查看更多 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // Copyright (c) 2015年 Ariel. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MainViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | 23 | MainViewController *controller = [[MainViewController alloc] init]; 24 | self.window.rootViewController = controller; 25 | 26 | [self.window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.imooc.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 "NSArray+MASAdditions.h" 21 | #import "NSArray+MASShorthandAdditions.h" 22 | #import "MASConstraint.h" 23 | #import "MASCompositeConstraint.h" 24 | #import "MASViewAttribute.h" 25 | #import "MASViewConstraint.h" 26 | #import "MASConstraintMaker.h" 27 | #import "MASLayoutConstraint.h" 28 | #import "NSLayoutConstraint+MASDebugAdditions.h" 29 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.cloudling.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多Tests/UITableViewCell_______Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableViewCell_______Tests.m 3 | // UITableViewCell-展开查看更多Tests 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // Copyright (c) 2015年 Ariel. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UITableViewCell_______Tests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation UITableViewCell_______Tests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The attribute which the reciever relates to 24 | */ 25 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 26 | 27 | /** 28 | * The designated initializer. 29 | */ 30 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 31 | 32 | /** 33 | * Determine whether the layoutAttribute is a size attribute 34 | * 35 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 36 | */ 37 | - (BOOL)isSizeAttribute; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 = [super init]; 15 | if (!self) return nil; 16 | 17 | _view = view; 18 | _layoutAttribute = layoutAttribute; 19 | 20 | return self; 21 | } 22 | 23 | - (BOOL)isSizeAttribute { 24 | return self.layoutAttribute == NSLayoutAttributeWidth 25 | || self.layoutAttribute == NSLayoutAttributeHeight; 26 | } 27 | 28 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 29 | if ([viewAttribute isKindOfClass:self.class]) { 30 | return self.view == viewAttribute.view 31 | && self.layoutAttribute == viewAttribute.layoutAttribute; 32 | } 33 | return [super isEqual:viewAttribute]; 34 | } 35 | 36 | - (NSUInteger)hash { 37 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/View/MCCommentCell.h: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | 文件名称:MCCommentCell.h 3 | 作 者:李雪松 4 | 备 注: 5 | 创建时间:15/5/21. 6 | 修改历史: 7 | 版权信息: Copyright (c) 2015年 Beijing Mooc Technology Center ltd. All rights reserved. 8 | ***************************************************************/ 9 | 10 | #import 11 | @class MCCommentCell; 12 | @protocol MCCommentDelegate 13 | 14 | - (void)commentOpenButtonClick:(MCCommentCell *)currentCell; 15 | - (void)userIconClick:(MCCommentCell *)cell; 16 | 17 | @end 18 | @interface MCCommentCell : UITableViewCell 19 | 20 | @property (nonatomic, weak) id delegate; 21 | 22 | @property (strong, nonatomic) id cellData; 23 | /** 24 | * 用户头像 25 | */ 26 | @property (strong, nonatomic) UIImageView *userIcon; 27 | /** 28 | * 用户昵称 29 | */ 30 | @property (strong, nonatomic) UILabel *nameLabel; 31 | /** 32 | * 评论日期 33 | */ 34 | @property (strong, nonatomic) UILabel *commentDateLabel; 35 | /** 36 | * 评论内容 37 | */ 38 | @property (strong, nonatomic) UILabel *commentDetail; 39 | /** 40 | * 分割线 41 | */ 42 | @property (strong, nonatomic) UIView *splitLine; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/Model/MCCommnetModel.h: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | 文件名称:MCCommnetModel.h 3 | 作 者:李雪松 4 | 备 注: 5 | 创建时间:15/5/22. 6 | 修改历史: 7 | 版权信息: Copyright (c) 2015年 Beijing Mooc Technology Center ltd. All rights reserved. 8 | ***************************************************************/ 9 | 10 | #import 11 | #import "Common.h" 12 | 13 | @interface MCCommnetModel : NSObject 14 | /** 15 | * 用户的ID 16 | */ 17 | @property (nonatomic, assign) long uid; 18 | /** 19 | * 用户的昵称 20 | */ 21 | @property (nonatomic, strong) NSString *nickName; 22 | /** 23 | * 用户头像的 URL 24 | */ 25 | @property (nonatomic, strong) NSString *pic; 26 | /** 27 | * 评论内容 28 | */ 29 | @property (strong, nonatomic) NSString *content; 30 | /** 31 | * 评论的ID 32 | */ 33 | //@property (nonatomic, assign) MCLong Id; 34 | /** 35 | * 评论日期 36 | */ 37 | @property (nonatomic, strong) NSString *publishTime; 38 | /** 39 | * 评论数 (时时更新) 需要返回 40 | */ 41 | @property (nonatomic, assign) long commentnum; 42 | 43 | /** 44 | * 展开还是关闭 (YES numberOfLine 为0, NO numberOfLine 为 3 ) 45 | * 此为本地,非网络获取的值,用来保存 commnentDetail 这个 Label 的行数 46 | */ 47 | @property (nonatomic, assign) BOOL isOpenAllCommentDetail; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Common.h: -------------------------------------------------------------------------------- 1 | 2 | //*********************************************** 3 | //********** 日志输出宏定义 ************* 4 | //*********************************************** 5 | #ifdef DEBUG 6 | #define LSLog(...) NSLog(__VA_ARGS__) 7 | #else 8 | #define LSLog(...) 9 | #endif 10 | //*********************************************** 11 | //*********************************************** 12 | //*********************************************** 13 | 14 | #import "Masonry.h" 15 | //#import "MJExtension.h" 16 | //#import "UIImageView+WebCache.h" 17 | 18 | #define IOS7 ([[[[UIDevice currentDevice]systemVersion]substringToIndex:1] doubleValue]>=7) 19 | #define IOS8 ([[[[UIDevice currentDevice]systemVersion]substringToIndex:1] doubleValue]>=8) 20 | #define IOS7_HEIGHT (IOS7 ? 20 : 0) 21 | 22 | 23 | #define APP_SCREEN_BOUNDS [[UIScreen mainScreen] bounds] 24 | #define APP_SCREEN_HEIGHT (APP_SCREEN_BOUNDS.size.height) 25 | #define APP_SCREEN_WIDTH (APP_SCREEN_BOUNDS.size.width) 26 | #define APP_STATUS_FRAME [UIApplication sharedApplication].statusBarFrame 27 | #define APP_CONTENT_WIDTH (APP_SCREEN_BOUNDS.size.width) 28 | #define APP_CONTENT_HEIGHT (IOS7?(APP_SCREEN_BOUNDS.size.height):(APP_SCREEN_BOUNDS.size.height-APP_STATUS_FRAME.size.height)) 29 | 30 | 31 | //RGB 三个参数数值相同 32 | #define UIColorFromSameRGB(r) [UIColor colorWithRed:(r)/255.0f green:(r)/255.0f blue:(r)/255.0f alpha:1] 33 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | @end 42 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.imooc.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | 27 | UIMainStoryboardFile 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarTintParameters 34 | 35 | UINavigationBar 36 | 37 | Style 38 | UIBarStyleDefault 39 | Translucent 40 | 41 | 42 | 43 | UISupportedInterfaceOrientations 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | @interface NSArray (MASAdditions) 14 | 15 | /** 16 | * Creates a MASConstraintMaker with each view in the callee. 17 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 18 | * 19 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 20 | * 21 | * @return Array of created MASConstraints 22 | */ 23 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 24 | 25 | /** 26 | * Creates a MASConstraintMaker with each view in the callee. 27 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 28 | * If an existing constraint exists then it will be updated instead. 29 | * 30 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 31 | * 32 | * @return Array of created/updated MASConstraints 33 | */ 34 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | /** 37 | * Creates a MASConstraintMaker with each view in the callee. 38 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 39 | * All constraints previously installed for the views will be removed. 40 | * 41 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 42 | * 43 | * @return Array of created/updated MASConstraints 44 | */ 45 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/Controller/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // 4 | // 5 | // Created by Ariel on 15/7/8. 6 | // 7 | // 8 | 9 | #import "MainViewController.h" 10 | #import "MCCommentCell.h" 11 | #import "MCCommnetModel.h" 12 | 13 | @interface MainViewController () < UITableViewDelegate, 14 | UITableViewDataSource, 15 | MCCommentDelegate> 16 | 17 | @property (nonatomic, strong) UITableView *tableView; // tabelView 18 | @property (nonatomic, strong) UIView *toolBar; // 底部的toolBar 19 | @property (nonatomic, strong) NSMutableArray *commentData; 20 | 21 | @end 22 | 23 | NSString *const cellID = @"commnetCell"; 24 | 25 | @implementation MainViewController 26 | 27 | #pragma mark - lifeCycle 28 | - (void)viewDidLoad { 29 | 30 | [super viewDidLoad]; 31 | self.view.backgroundColor = UIColorFromSameRGB(241); 32 | 33 | 34 | [self initLoadData]; // 初始化评论数据 35 | 36 | [self initTabelView]; // 初始化tableView 37 | [self initToolBar]; // 初始化toolBar 38 | 39 | // [self initNavigationBar]; // 初始化导航栏 40 | // [self setAllConstraints]; // 设置所有的约束 41 | } 42 | 43 | #pragma mark - privateMethods 44 | #pragma mark 导航栏 45 | - (void)initNavigationBar { 46 | 47 | } 48 | 49 | #pragma mark 初始化 tableView 50 | - (void)initTabelView { 51 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, APP_CONTENT_WIDTH, APP_CONTENT_HEIGHT)]; 52 | _tableView.delegate = self; 53 | _tableView.dataSource = self; 54 | _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 55 | [_tableView registerClass:[MCCommentCell class] forCellReuseIdentifier:cellID]; 56 | [self.view addSubview:_tableView]; 57 | } 58 | 59 | #pragma mark 初始化 60 | - (void)initToolBar { 61 | 62 | } 63 | 64 | #pragma mark - UITableViewDelegate and UITableViewDataSource 65 | #pragma mark 每个分区的行数 66 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 67 | return self.commentData.count; 68 | } 69 | 70 | #pragma mark 行高 71 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 72 | static MCCommentCell *cell = nil; 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | cell = [self.tableView dequeueReusableCellWithIdentifier:cellID]; 76 | }); 77 | [self configureCell:cell atIndexPath:indexPath]; 78 | return [self calculateHeightForCell:cell]; 79 | } 80 | 81 | - (CGFloat)calculateHeightForCell:(MCCommentCell *)cell { 82 | [cell setNeedsLayout]; 83 | [cell layoutIfNeeded]; 84 | CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; 85 | return ceilf(size.height); 86 | } 87 | 88 | - (void)configureCell:(MCCommentCell *)cell atIndexPath:(NSIndexPath *)indexPath { 89 | cell.cellData = self.commentData[indexPath.row]; 90 | cell.delegate = self; 91 | } 92 | 93 | 94 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 95 | 96 | MCCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; 97 | [self configureCell:cell atIndexPath:indexPath]; 98 | return cell; 99 | } 100 | 101 | #pragma mark 点击展开按钮 102 | - (void)commentOpenButtonClick:(MCCommentCell *)currentCell { 103 | 104 | NSIndexPath *indepath = [_tableView indexPathForCell:currentCell]; 105 | MCCommnetModel *model = _commentData[indepath.row]; 106 | model.isOpenAllCommentDetail = !model.isOpenAllCommentDetail; 107 | [self.tableView reloadRowsAtIndexPaths:@[indepath] withRowAnimation:UITableViewRowAnimationAutomatic]; 108 | } 109 | 110 | #pragma mark 用户头像的点击事件 111 | - (void)userIconClick:(MCCommentCell *)cell { 112 | 113 | } 114 | 115 | - (void)initLoadData { 116 | 117 | MCCommnetModel *model1 = [[MCCommnetModel alloc] init]; 118 | model1.nickName = @"三妓淫领生活"; 119 | model1.pic = @"IMG_0016"; 120 | model1.publishTime = @"2015-06-11"; 121 | model1.content = @"网易河北讯 夜里3:50许,闹铃响了,张女士和丈夫睁眼发现,小偷正趴在卧室的阳台上。震惊之余,丈夫起身追赶,没想到小偷顺势从三楼外墙管道溜下。合肥一名女业主在7月2日家中被盗后,冥冥中感觉贼会再次“光顾”,便在上次失窃的时间定好闹钟。事隔一天后,小偷果然“故地重游”,被女业主恰巧看见。遗憾的是,小偷还是跑掉了。"; 122 | 123 | MCCommnetModel *model2 = [[MCCommnetModel alloc] init]; 124 | model2.nickName = @"嗯哼~"; 125 | model2.pic = @"2245"; 126 | model2.publishTime = @"2015-06-11"; 127 | model2.content = @"嗯哼~"; 128 | 129 | MCCommnetModel *model3 = [[MCCommnetModel alloc] init]; 130 | model3.nickName = @"嗯哼哼~~"; 131 | model3.pic = @"1123"; 132 | model3.publishTime = @"2015-06-11"; 133 | model3.content = @"嗯哼哼~~"; 134 | 135 | MCCommnetModel *model4 = [[MCCommnetModel alloc] init]; 136 | model4.nickName = @"太奇葩!"; 137 | model4.pic = @"4455"; 138 | model4.publishTime = @"2015-06-11"; 139 | model4.content = @"太奇葩!难道剁饺子馅能将阳台掉下楼?原来沈阳市大东区合作街120号的梧桐园小区发生楼体坍塌事故,7楼住户在家客厅好好地剁饺子馅,没想到7楼和6楼阳台整个掉到5楼,直将目击者惊呆了,所幸事发时2阳台上都没人,因此未造成人员伤亡,据悉事发小区有居民看见阳台与楼体之间断裂的部分之后发现楼板里面看不见粗钢筋。经多位该小区居民证实,这几栋回迁楼2002年入住,至今楼龄只有13年。现在该住户已经住到旅店。"; 140 | 141 | NSArray *array = @[model1, model2, model3, model4]; 142 | _commentData = [NSMutableArray arrayWithArray:array]; 143 | } 144 | 145 | @end 146 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/xcuserdata/Ariel.xcuserdatad/xcschemes/UITableViewCell-展开查看更多.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 TARGET_OS_IPHONE 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MASEdgeInsets UIEdgeInsets 16 | 17 | typedef UILayoutPriority MASLayoutPriority; 18 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 19 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 22 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 23 | 24 | #elif TARGET_OS_MAC 25 | 26 | #import 27 | #define MAS_VIEW NSView 28 | #define MASEdgeInsets NSEdgeInsets 29 | 30 | typedef NSLayoutPriority MASLayoutPriority; 31 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 32 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 33 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 34 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 35 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 38 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 39 | 40 | #endif 41 | 42 | /** 43 | * Allows you to attach keys to objects matching the variable names passed. 44 | * 45 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 46 | * 47 | * is equivalent to: 48 | * 49 | * MASAttachKeys(view1, view2); 50 | */ 51 | #define MASAttachKeys(...) \ 52 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 53 | for (id key in keyPairs.allKeys) { \ 54 | id obj = keyPairs[key]; \ 55 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 56 | @"Cannot attach mas_key to %@", obj); \ 57 | [obj setMas_key:key]; \ 58 | } 59 | 60 | /** 61 | * Used to create object hashes 62 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 63 | */ 64 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 65 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 66 | 67 | /** 68 | * Given a scalar or struct value, wraps it in NSValue 69 | * Based on EXPObjectify: https://github.com/specta/expecta 70 | */ 71 | static inline id _MASBoxValue(const char *type, ...) { 72 | va_list v; 73 | va_start(v, type); 74 | id obj = nil; 75 | if (strcmp(type, @encode(id)) == 0) { 76 | id actual = va_arg(v, id); 77 | obj = actual; 78 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 79 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 80 | obj = [NSValue value:&actual withObjCType:type]; 81 | } else if (strcmp(type, @encode(CGSize)) == 0) { 82 | CGSize actual = (CGSize)va_arg(v, CGSize); 83 | obj = [NSValue value:&actual withObjCType:type]; 84 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 85 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 86 | obj = [NSValue value:&actual withObjCType:type]; 87 | } else if (strcmp(type, @encode(double)) == 0) { 88 | double actual = (double)va_arg(v, double); 89 | obj = [NSNumber numberWithDouble:actual]; 90 | } else if (strcmp(type, @encode(float)) == 0) { 91 | float actual = (float)va_arg(v, double); 92 | obj = [NSNumber numberWithFloat:actual]; 93 | } else if (strcmp(type, @encode(int)) == 0) { 94 | int actual = (int)va_arg(v, int); 95 | obj = [NSNumber numberWithInt:actual]; 96 | } else if (strcmp(type, @encode(long)) == 0) { 97 | long actual = (long)va_arg(v, long); 98 | obj = [NSNumber numberWithLong:actual]; 99 | } else if (strcmp(type, @encode(long long)) == 0) { 100 | long long actual = (long long)va_arg(v, long long); 101 | obj = [NSNumber numberWithLongLong:actual]; 102 | } else if (strcmp(type, @encode(short)) == 0) { 103 | short actual = (short)va_arg(v, int); 104 | obj = [NSNumber numberWithShort:actual]; 105 | } else if (strcmp(type, @encode(char)) == 0) { 106 | char actual = (char)va_arg(v, int); 107 | obj = [NSNumber numberWithChar:actual]; 108 | } else if (strcmp(type, @encode(bool)) == 0) { 109 | bool actual = (bool)va_arg(v, int); 110 | obj = [NSNumber numberWithBool:actual]; 111 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 112 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 113 | obj = [NSNumber numberWithUnsignedChar:actual]; 114 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 115 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 116 | obj = [NSNumber numberWithUnsignedInt:actual]; 117 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 118 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 119 | obj = [NSNumber numberWithUnsignedLong:actual]; 120 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 121 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 122 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 123 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 124 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 125 | obj = [NSNumber numberWithUnsignedShort:actual]; 126 | } 127 | va_end(v); 128 | return obj; 129 | } 130 | 131 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 132 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 TARGET_OS_IPHONE 131 | 132 | - (MASConstraint *)leftMargin; 133 | - (MASConstraint *)rightMargin; 134 | - (MASConstraint *)topMargin; 135 | - (MASConstraint *)bottomMargin; 136 | - (MASConstraint *)leadingMargin; 137 | - (MASConstraint *)trailingMargin; 138 | - (MASConstraint *)centerXWithinMargins; 139 | - (MASConstraint *)centerYWithinMargins; 140 | 141 | #endif 142 | 143 | 144 | /** 145 | * Sets the constraint debug name 146 | */ 147 | - (MASConstraint * (^)(id key))key; 148 | 149 | // NSLayoutConstraint constant Setters 150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 156 | */ 157 | - (void)setInsets:(MASEdgeInsets)insets; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 163 | */ 164 | - (void)setSizeOffset:(CGSize)sizeOffset; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 170 | */ 171 | - (void)setCenterOffset:(CGPoint)centerOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant 175 | */ 176 | - (void)setOffset:(CGFloat)offset; 177 | 178 | 179 | // NSLayoutConstraint Installation support 180 | 181 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 182 | /** 183 | * Whether or not to go through the animator proxy when modifying the constraint 184 | */ 185 | @property (nonatomic, copy, readonly) MASConstraint *animator; 186 | #endif 187 | 188 | /** 189 | * Activates an NSLayoutConstraint if it's supported by an OS. 190 | * Invokes install otherwise. 191 | */ 192 | - (void)activate; 193 | 194 | /** 195 | * Deactivates previously installed/activated NSLayoutConstraint. 196 | */ 197 | - (void)deactivate; 198 | 199 | /** 200 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 201 | */ 202 | - (void)install; 203 | 204 | /** 205 | * Removes previously installed NSLayoutConstraint 206 | */ 207 | - (void)uninstall; 208 | 209 | @end 210 | 211 | 212 | /** 213 | * Convenience auto-boxing macros for MASConstraint methods. 214 | * 215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 216 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 217 | */ 218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 221 | 222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 223 | 224 | 225 | #ifdef MAS_SHORTHAND_GLOBALS 226 | 227 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 230 | 231 | #define offset(...) mas_offset(__VA_ARGS__) 232 | 233 | #endif 234 | 235 | 236 | @interface MASConstraint (AutoboxingSupport) 237 | 238 | /** 239 | * Aliases to corresponding relation methods (for shorthand macros) 240 | * Also needed to aid autocompletion 241 | */ 242 | - (MASConstraint * (^)(id attr))mas_equalTo; 243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 245 | 246 | /** 247 | * A dummy method to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id offset))mas_offset; 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 TARGET_OS_IPHONE 212 | 213 | - (MASConstraint *)leftMargin { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 215 | } 216 | 217 | - (MASConstraint *)rightMargin { 218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 219 | } 220 | 221 | - (MASConstraint *)topMargin { 222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 223 | } 224 | 225 | - (MASConstraint *)bottomMargin { 226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 227 | } 228 | 229 | - (MASConstraint *)leadingMargin { 230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 231 | } 232 | 233 | - (MASConstraint *)trailingMargin { 234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 235 | } 236 | 237 | - (MASConstraint *)centerXWithinMargins { 238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 239 | } 240 | 241 | - (MASConstraint *)centerYWithinMargins { 242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 243 | } 244 | 245 | #endif 246 | 247 | #pragma mark - Abstract 248 | 249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 250 | 251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 252 | 253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 254 | 255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 256 | 257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 258 | 259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 260 | 261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 262 | 263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 264 | 265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 266 | 267 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 268 | 269 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 270 | 271 | #endif 272 | 273 | - (void)activate { MASMethodNotImplemented(); } 274 | 275 | - (void)deactivate { MASMethodNotImplemented(); } 276 | 277 | - (void)install { MASMethodNotImplemented(); } 278 | 279 | - (void)uninstall { MASMethodNotImplemented(); } 280 | 281 | @end 282 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/Classes/View/MCCommentCell.m: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | 文件名称:MCCommentCell.m 3 | 作 者:李雪松 4 | 备 注: 5 | 创建时间:15/5/21. 6 | 修改历史: 7 | 版权信息: Copyright (c) 2015年 Beijing ‘ Technology Center ltd. All rights reserved. 8 | ***************************************************************/ 9 | 10 | #import "MCCommentCell.h" 11 | #import "MCCommnetModel.h" 12 | 13 | @interface MCCommentCell () 14 | { 15 | UIButton *_btn; 16 | CGSize _commentDetailSize; 17 | } 18 | 19 | @end 20 | 21 | @implementation MCCommentCell 22 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 23 | 24 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 25 | 26 | // 0. 设置cell的背景以及选时中背景颜色 27 | self.backgroundColor = [UIColor whiteColor]; 28 | self.selectionStyle = UITableViewCellSelectionStyleNone; 29 | 30 | // 1. 设置cell的子控件 31 | [self setSubViews]; 32 | 33 | // 2. 设置cell子控件的属性样式 34 | [self setSubViewsOfStyle]; 35 | 36 | // 2. 设置cell内部子控件的约束 37 | [self setAllConstraints]; 38 | 39 | } 40 | return self; 41 | } 42 | 43 | // 设置cell的子控件 44 | - (void)setSubViews { 45 | 46 | _userIcon = [[UIImageView alloc] init]; // 用户头像 47 | [self.contentView addSubview:_userIcon]; 48 | 49 | _nameLabel = [[UILabel alloc] init]; // 用户昵称 50 | [self.contentView addSubview:_nameLabel]; 51 | 52 | _commentDateLabel = [[UILabel alloc] init]; // 评论日期 53 | [self.contentView addSubview:_commentDateLabel]; 54 | 55 | _commentDetail = [[UILabel alloc] init]; // 评论内容 56 | [self.contentView addSubview:_commentDetail]; 57 | 58 | _btn = [[UIButton alloc] init]; // 展开按钮 59 | [self.contentView addSubview:_btn]; 60 | 61 | _splitLine = [[UIView alloc] init]; // cell 分割线 62 | [self.contentView addSubview:_splitLine]; 63 | } 64 | 65 | // 设置cell内部的数据 66 | - (void)setCellData:(id)cellData { 67 | 68 | // 0. 获取模型的数据 69 | MCCommnetModel *model = cellData; 70 | 71 | // 1. 设置cell的数据 72 | UIImage *imageName = [UIImage imageNamed:model.pic]; 73 | // [self.userIcon sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:imageName]; 74 | [self.userIcon setImage:imageName]; 75 | 76 | self.nameLabel.text = model.nickName; 77 | self.commentDateLabel.text = model.publishTime; 78 | self.commentDetail.text = model.content; 79 | _commentDetail.numberOfLines = model.isOpenAllCommentDetail ? 0 : 3; 80 | [_btn setTitle:model.isOpenAllCommentDetail ? @"收起" : @"展开" forState:UIControlStateNormal]; 81 | 82 | // 2. 更改cell的样式、超过评论内容超过 3 行,显示展开按钮 83 | [self changeCellStyle]; 84 | } 85 | 86 | - (void)changeCellStyle { 87 | 88 | // 1. 计算cell数据内容的大小以及尺寸 89 | CGSize size = [_commentDetail.text sizeWithFont:_commentDetail.font constrainedToSize:CGSizeMake(APP_CONTENT_WIDTH-75, 999)lineBreakMode:NSLineBreakByWordWrapping]; 90 | 91 | _commentDetailSize.width = ceilf(size.width); 92 | _commentDetailSize.height = ceilf(size.height); 93 | 94 | if ( _commentDetailSize.height > 51) { 95 | 96 | // 评论内容超过 3 行 ,显示 展开按钮 97 | _btn.hidden = NO; 98 | 99 | // 添加展开按钮,并更新评论详情内容的约束 100 | [self setButtomConstraints]; 101 | 102 | 103 | }else { 104 | 105 | // 评论内容未超过 3 行 ,不需要显示 展开按钮 106 | _btn.hidden = YES; 107 | 108 | /* // 这里不能使用 update 来更新它的约束,会造成后台系统警告,所以重新制定约束 109 | // 更新评论框的约束 110 | [_commentDetail mas_updateConstraints:^(MASConstraintMaker *make) { 111 | make.height.equalTo(@(_commentDetailSize.height)); 112 | make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-15); 113 | }]; 114 | */ 115 | 116 | // 重新设置约束 117 | [_commentDetail mas_remakeConstraints:^(MASConstraintMaker *make) { 118 | make.top.equalTo(_nameLabel.mas_bottom).with.offset(15); 119 | make.left.equalTo(_nameLabel.mas_left); 120 | make.right.equalTo(_commentDateLabel.mas_right); 121 | make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-15); 122 | }]; 123 | } 124 | } 125 | 126 | #pragma mark 设置cell子控件的属性样式 127 | - (void)setSubViewsOfStyle { 128 | 129 | _userIcon.userInteractionEnabled = YES; 130 | [_userIcon setUserInteractionEnabled:YES]; 131 | [_userIcon addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headeImageViewClick)]]; 132 | 133 | _nameLabel.font = [UIFont systemFontOfSize:14]; // 14px 134 | _nameLabel.textColor = UIColorFromSameRGB(153); 135 | _commentDateLabel.font = _nameLabel.font; 136 | _commentDateLabel.textColor = _nameLabel.textColor; 137 | _commentDateLabel.textAlignment = NSTextAlignmentRight; 138 | _commentDetail.numberOfLines = 3; 139 | _commentDetail.font = [UIFont systemFontOfSize:14]; // 字体 14 140 | _commentDetail.textColor = UIColorFromSameRGB(51); // RGB 51 141 | _btn.backgroundColor = [UIColor whiteColor]; 142 | _btn.titleLabel.font = [UIFont systemFontOfSize:12]; // 字体 12 143 | [_btn setTitleColor:UIColorFromSameRGB(51) forState:UIControlStateNormal]; // RGB 153 144 | _btn.layer.borderWidth = 0.5f; 145 | _btn.layer.borderColor = [UIColorFromSameRGB(153) CGColor]; // RGB 153 146 | _btn.layer.cornerRadius = 2; 147 | _btn.clipsToBounds = YES; 148 | [_btn addTarget:self action:@selector(openCommentDetail:) forControlEvents:UIControlEventTouchUpInside]; 149 | _splitLine.backgroundColor = UIColorFromSameRGB(218); 150 | 151 | // 参照最大值 152 | CGFloat preferredWidth = APP_CONTENT_WIDTH - 75; 153 | _nameLabel.preferredMaxLayoutWidth = preferredWidth; 154 | _commentDetail.preferredMaxLayoutWidth = preferredWidth; 155 | 156 | } 157 | #pragma mark - 设置约束 158 | #pragma mark 设置subViews的约束 159 | - (void)setAllConstraints { 160 | 161 | _userIcon.backgroundColor = [UIColor greenColor]; 162 | _nameLabel.backgroundColor = [UIColor greenColor]; 163 | _commentDateLabel.backgroundColor = [UIColor redColor]; 164 | _btn.backgroundColor = [UIColor yellowColor]; 165 | _commentDetail.backgroundColor = [UIColor yellowColor]; 166 | _splitLine.backgroundColor = [UIColor redColor]; 167 | 168 | // 添加用户头像的约束 169 | [_userIcon mas_makeConstraints:^(MASConstraintMaker *make) { 170 | make.width.height.equalTo(@30); 171 | _userIcon.layer.cornerRadius = 15; 172 | _userIcon.clipsToBounds = YES; 173 | make.top.left.equalTo(self.contentView).with.offset(15); 174 | }]; 175 | 176 | // 添加用户名称的约束 177 | [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { 178 | make.top.equalTo(self.contentView).with.offset(25).with.priority(751); 179 | make.left.equalTo(_userIcon.mas_right).with.offset(15); 180 | make.right.equalTo(_commentDateLabel.mas_left).with.offset(-10); 181 | make.height.equalTo(@14); 182 | }]; 183 | 184 | // 添加评论日期的约束 185 | [_commentDateLabel mas_makeConstraints:^(MASConstraintMaker *make) { 186 | make.top.equalTo(_nameLabel.mas_top); 187 | make.width.equalTo(@80); 188 | make.right.equalTo(self.contentView.mas_right).with.offset(-15); 189 | make.height.equalTo(_nameLabel.mas_height); 190 | }]; 191 | 192 | // 添加评论内容的约束 193 | [_commentDetail mas_makeConstraints:^(MASConstraintMaker *make) { 194 | make.top.equalTo(_nameLabel.mas_bottom).with.offset(15); 195 | make.left.equalTo(_nameLabel.mas_left); 196 | make.right.equalTo(_commentDateLabel.mas_right); 197 | // make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-15); 198 | make.height.equalTo(@51); 199 | }]; 200 | 201 | // 添加分割线的约束 202 | [_splitLine mas_makeConstraints:^(MASConstraintMaker *make) { 203 | make.left.equalTo(self.contentView.mas_left).with.offset(15); 204 | make.right.equalTo(_commentDateLabel.mas_right); 205 | make.height.equalTo(@.5); 206 | make.bottom.equalTo(self.contentView.mas_bottom); 207 | }]; 208 | } 209 | #pragma mark 设置展开按钮的约束 210 | - (void)setButtomConstraints { 211 | 212 | [_btn mas_remakeConstraints:^(MASConstraintMaker *make) { 213 | make.right.equalTo(_commentDetail.mas_right); // x 214 | make.width.equalTo(@39); // W 215 | make.height.equalTo(@18); // H 216 | make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-15); // y 217 | }]; 218 | 219 | [_commentDetail mas_remakeConstraints:^(MASConstraintMaker *make) { 220 | make.top.equalTo(_nameLabel.mas_bottom).with.offset(15); 221 | make.left.equalTo(_nameLabel.mas_left); 222 | make.right.equalTo(_commentDateLabel.mas_right); 223 | make.bottom.equalTo(_btn.mas_top).with.offset(-15); 224 | }]; 225 | } 226 | 227 | #pragma mark 展开评论按钮 228 | - (void)openCommentDetail:(UIButton *)sender { 229 | 230 | if ([_delegate respondsToSelector:@selector(commentOpenButtonClick:)]) { 231 | 232 | if ([_btn.titleLabel.text isEqualToString:@"展开"]) { 233 | [_btn setTitle:@"收起" forState:UIControlStateNormal]; 234 | }else { 235 | [_btn setTitle:@"展开" forState:UIControlStateNormal]; 236 | } 237 | 238 | [_delegate commentOpenButtonClick:self]; 239 | } 240 | 241 | } 242 | 243 | #pragma mark 头像的点击事件 244 | -(void)headeImageViewClick 245 | { 246 | if([_delegate respondsToSelector:@selector(userIconClick:)]) { 247 | [_delegate userIconClick:self]; 248 | } 249 | } 250 | 251 | 252 | 253 | 254 | @end 255 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 TARGET_OS_IPHONE 82 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 83 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 84 | | MASAttributeCenterYWithinMargins 85 | #endif 86 | ); 87 | 88 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 89 | 90 | NSMutableArray *attributes = [NSMutableArray array]; 91 | 92 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 93 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 94 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 95 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 96 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 97 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 98 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 99 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 100 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 101 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 102 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 103 | 104 | #if TARGET_OS_IPHONE 105 | 106 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 107 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 108 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 109 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 110 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 111 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 112 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 113 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 114 | 115 | #endif 116 | 117 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 118 | 119 | for (MASViewAttribute *a in attributes) { 120 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 121 | } 122 | 123 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 124 | constraint.delegate = self; 125 | [self.constraints addObject:constraint]; 126 | return constraint; 127 | } 128 | 129 | #pragma mark - standard Attributes 130 | 131 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 132 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 133 | } 134 | 135 | - (MASConstraint *)left { 136 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 137 | } 138 | 139 | - (MASConstraint *)top { 140 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 141 | } 142 | 143 | - (MASConstraint *)right { 144 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 145 | } 146 | 147 | - (MASConstraint *)bottom { 148 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 149 | } 150 | 151 | - (MASConstraint *)leading { 152 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 153 | } 154 | 155 | - (MASConstraint *)trailing { 156 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 157 | } 158 | 159 | - (MASConstraint *)width { 160 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 161 | } 162 | 163 | - (MASConstraint *)height { 164 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 165 | } 166 | 167 | - (MASConstraint *)centerX { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 169 | } 170 | 171 | - (MASConstraint *)centerY { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 173 | } 174 | 175 | - (MASConstraint *)baseline { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 177 | } 178 | 179 | - (MASConstraint *(^)(MASAttribute))attributes { 180 | return ^(MASAttribute attrs){ 181 | return [self addConstraintWithAttributes:attrs]; 182 | }; 183 | } 184 | 185 | #if TARGET_OS_IPHONE 186 | 187 | - (MASConstraint *)leftMargin { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 189 | } 190 | 191 | - (MASConstraint *)rightMargin { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 193 | } 194 | 195 | - (MASConstraint *)topMargin { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 197 | } 198 | 199 | - (MASConstraint *)bottomMargin { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 201 | } 202 | 203 | - (MASConstraint *)leadingMargin { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 205 | } 206 | 207 | - (MASConstraint *)trailingMargin { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 209 | } 210 | 211 | - (MASConstraint *)centerXWithinMargins { 212 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 213 | } 214 | 215 | - (MASConstraint *)centerYWithinMargins { 216 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 217 | } 218 | 219 | #endif 220 | 221 | 222 | #pragma mark - composite Attributes 223 | 224 | - (MASConstraint *)edges { 225 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 226 | } 227 | 228 | - (MASConstraint *)size { 229 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 230 | } 231 | 232 | - (MASConstraint *)center { 233 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 234 | } 235 | 236 | #pragma mark - grouping 237 | 238 | - (MASConstraint *(^)(dispatch_block_t group))group { 239 | return ^id(dispatch_block_t group) { 240 | NSInteger previousCount = self.constraints.count; 241 | group(); 242 | 243 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 244 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 245 | constraint.delegate = self; 246 | return constraint; 247 | }; 248 | } 249 | 250 | @end 251 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多/lib/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 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 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 | if ([self supportsActiveProperty] && self.layoutConstraint) { 292 | if (self.hasBeenInstalled) { 293 | return; 294 | } 295 | self.layoutConstraint.active = YES; 296 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 297 | } else { 298 | [self install]; 299 | } 300 | } 301 | 302 | - (void)deactivate { 303 | if ([self supportsActiveProperty]) { 304 | self.layoutConstraint.active = NO; 305 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 306 | } else { 307 | [self uninstall]; 308 | } 309 | } 310 | 311 | - (void)install { 312 | if (self.hasBeenInstalled) { 313 | return; 314 | } 315 | 316 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.view; 317 | 318 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 319 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.view; 320 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 321 | 322 | // alignment attributes must have a secondViewAttribute 323 | // therefore we assume that is refering to superview 324 | // eg make.left.equalTo(@10) 325 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 326 | secondLayoutItem = firstLayoutItem.superview; 327 | secondLayoutAttribute = firstLayoutAttribute; 328 | } 329 | 330 | MASLayoutConstraint *layoutConstraint 331 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 332 | attribute:firstLayoutAttribute 333 | relatedBy:self.layoutRelation 334 | toItem:secondLayoutItem 335 | attribute:secondLayoutAttribute 336 | multiplier:self.layoutMultiplier 337 | constant:self.layoutConstant]; 338 | 339 | layoutConstraint.priority = self.layoutPriority; 340 | layoutConstraint.mas_key = self.mas_key; 341 | 342 | if (secondLayoutItem) { 343 | MAS_VIEW *closestCommonSuperview = [firstLayoutItem mas_closestCommonSuperview:secondLayoutItem]; 344 | NSAssert(closestCommonSuperview, 345 | @"couldn't find a common superview for %@ and %@", 346 | firstLayoutItem, secondLayoutItem); 347 | self.installedView = closestCommonSuperview; 348 | } else { 349 | self.installedView = firstLayoutItem; 350 | } 351 | 352 | 353 | MASLayoutConstraint *existingConstraint = nil; 354 | if (self.updateExisting) { 355 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 356 | } 357 | if (existingConstraint) { 358 | // just update the constant 359 | existingConstraint.constant = layoutConstraint.constant; 360 | self.layoutConstraint = existingConstraint; 361 | } else { 362 | [self.installedView addConstraint:layoutConstraint]; 363 | self.layoutConstraint = layoutConstraint; 364 | [firstLayoutItem.mas_installedConstraints addObject:self]; 365 | } 366 | } 367 | 368 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 369 | // check if any constraints are the same apart from the only mutable property constant 370 | 371 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 372 | // and they are likely to be added first. 373 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 374 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 375 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 376 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 377 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 378 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 379 | if (existingConstraint.relation != layoutConstraint.relation) continue; 380 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 381 | if (existingConstraint.priority != layoutConstraint.priority) continue; 382 | 383 | return (id)existingConstraint; 384 | } 385 | return nil; 386 | } 387 | 388 | - (void)uninstall { 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 | -------------------------------------------------------------------------------- /UITableViewCell-展开查看更多.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B0F829D21B4CF8C3002A0A6F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F829D11B4CF8C3002A0A6F /* main.m */; }; 11 | B0F829E01B4CF8C3002A0A6F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B0F829DF1B4CF8C3002A0A6F /* Images.xcassets */; }; 12 | B0F829EF1B4CF8C3002A0A6F /* UITableViewCell_______Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F829EE1B4CF8C3002A0A6F /* UITableViewCell_______Tests.m */; }; 13 | B0F829FB1B4CF959002A0A6F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F829F91B4CF959002A0A6F /* AppDelegate.m */; }; 14 | B0F82A061B4CF960002A0A6F /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F829FF1B4CF960002A0A6F /* MainViewController.m */; }; 15 | B0F82A071B4CF960002A0A6F /* MCCommnetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A021B4CF960002A0A6F /* MCCommnetModel.m */; }; 16 | B0F82A081B4CF960002A0A6F /* MCCommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A051B4CF960002A0A6F /* MCCommentCell.m */; }; 17 | B0F82A231B4CF982002A0A6F /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B0F82A0B1B4CF982002A0A6F /* Info.plist */; }; 18 | B0F82A241B4CF982002A0A6F /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A0D1B4CF982002A0A6F /* MASCompositeConstraint.m */; }; 19 | B0F82A251B4CF982002A0A6F /* MASConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A101B4CF982002A0A6F /* MASConstraint.m */; }; 20 | B0F82A261B4CF982002A0A6F /* MASConstraintMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A121B4CF982002A0A6F /* MASConstraintMaker.m */; }; 21 | B0F82A271B4CF982002A0A6F /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A141B4CF982002A0A6F /* MASLayoutConstraint.m */; }; 22 | B0F82A281B4CF982002A0A6F /* MASViewAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A181B4CF982002A0A6F /* MASViewAttribute.m */; }; 23 | B0F82A291B4CF982002A0A6F /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A1A1B4CF982002A0A6F /* MASViewConstraint.m */; }; 24 | B0F82A2A1B4CF982002A0A6F /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A1C1B4CF982002A0A6F /* NSArray+MASAdditions.m */; }; 25 | B0F82A2B1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A1F1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.m */; }; 26 | B0F82A2C1B4CF982002A0A6F /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F82A211B4CF982002A0A6F /* View+MASAdditions.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | B0F829E91B4CF8C3002A0A6F /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = B0F829C41B4CF8C2002A0A6F /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = B0F829CB1B4CF8C3002A0A6F; 35 | remoteInfo = "UITableViewCell-展开查看更多"; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | B0F829CC1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "UITableViewCell-展开查看更多.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | B0F829D01B4CF8C3002A0A6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | B0F829D11B4CF8C3002A0A6F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | B0F829DF1B4CF8C3002A0A6F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 44 | B0F829E81B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UITableViewCell-展开查看更多Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | B0F829ED1B4CF8C3002A0A6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | B0F829EE1B4CF8C3002A0A6F /* UITableViewCell_______Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITableViewCell_______Tests.m"; sourceTree = ""; }; 47 | B0F829F81B4CF959002A0A6F /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 48 | B0F829F91B4CF959002A0A6F /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 49 | B0F829FA1B4CF959002A0A6F /* Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Common.h; sourceTree = ""; }; 50 | B0F829FE1B4CF960002A0A6F /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 51 | B0F829FF1B4CF960002A0A6F /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 52 | B0F82A011B4CF960002A0A6F /* MCCommnetModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCCommnetModel.h; sourceTree = ""; }; 53 | B0F82A021B4CF960002A0A6F /* MCCommnetModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCCommnetModel.m; sourceTree = ""; }; 54 | B0F82A041B4CF960002A0A6F /* MCCommentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCCommentCell.h; sourceTree = ""; }; 55 | B0F82A051B4CF960002A0A6F /* MCCommentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCCommentCell.m; sourceTree = ""; }; 56 | B0F82A0B1B4CF982002A0A6F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | B0F82A0C1B4CF982002A0A6F /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = ""; }; 58 | B0F82A0D1B4CF982002A0A6F /* MASCompositeConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASCompositeConstraint.m; sourceTree = ""; }; 59 | B0F82A0E1B4CF982002A0A6F /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = ""; }; 60 | B0F82A0F1B4CF982002A0A6F /* MASConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraint.h; sourceTree = ""; }; 61 | B0F82A101B4CF982002A0A6F /* MASConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraint.m; sourceTree = ""; }; 62 | B0F82A111B4CF982002A0A6F /* MASConstraintMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintMaker.h; sourceTree = ""; }; 63 | B0F82A121B4CF982002A0A6F /* MASConstraintMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintMaker.m; sourceTree = ""; }; 64 | B0F82A131B4CF982002A0A6F /* MASLayoutConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLayoutConstraint.h; sourceTree = ""; }; 65 | B0F82A141B4CF982002A0A6F /* MASLayoutConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLayoutConstraint.m; sourceTree = ""; }; 66 | B0F82A151B4CF982002A0A6F /* Masonry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Masonry.h; sourceTree = ""; }; 67 | B0F82A161B4CF982002A0A6F /* MASUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASUtilities.h; sourceTree = ""; }; 68 | B0F82A171B4CF982002A0A6F /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = ""; }; 69 | B0F82A181B4CF982002A0A6F /* MASViewAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewAttribute.m; sourceTree = ""; }; 70 | B0F82A191B4CF982002A0A6F /* MASViewConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewConstraint.h; sourceTree = ""; }; 71 | B0F82A1A1B4CF982002A0A6F /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = ""; }; 72 | B0F82A1B1B4CF982002A0A6F /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = ""; }; 73 | B0F82A1C1B4CF982002A0A6F /* NSArray+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASAdditions.m"; sourceTree = ""; }; 74 | B0F82A1D1B4CF982002A0A6F /* NSArray+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASShorthandAdditions.h"; sourceTree = ""; }; 75 | B0F82A1E1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MASDebugAdditions.h"; sourceTree = ""; }; 76 | B0F82A1F1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = ""; }; 77 | B0F82A201B4CF982002A0A6F /* View+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASAdditions.h"; sourceTree = ""; }; 78 | B0F82A211B4CF982002A0A6F /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = ""; }; 79 | B0F82A221B4CF982002A0A6F /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = ""; }; 80 | /* End PBXFileReference section */ 81 | 82 | /* Begin PBXFrameworksBuildPhase section */ 83 | B0F829C91B4CF8C3002A0A6F /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | B0F829E51B4CF8C3002A0A6F /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | /* End PBXFrameworksBuildPhase section */ 98 | 99 | /* Begin PBXGroup section */ 100 | B0F829C31B4CF8C2002A0A6F = { 101 | isa = PBXGroup; 102 | children = ( 103 | B0F829CE1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多 */, 104 | B0F829EB1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests */, 105 | B0F829CD1B4CF8C3002A0A6F /* Products */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | B0F829CD1B4CF8C3002A0A6F /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | B0F829CC1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多.app */, 113 | B0F829E81B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests.xctest */, 114 | ); 115 | name = Products; 116 | sourceTree = ""; 117 | }; 118 | B0F829CE1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多 */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | B0F82A091B4CF982002A0A6F /* lib */, 122 | B0F829FC1B4CF960002A0A6F /* Classes */, 123 | B0F829DF1B4CF8C3002A0A6F /* Images.xcassets */, 124 | B0F829CF1B4CF8C3002A0A6F /* Supporting Files */, 125 | ); 126 | path = "UITableViewCell-展开查看更多"; 127 | sourceTree = ""; 128 | }; 129 | B0F829CF1B4CF8C3002A0A6F /* Supporting Files */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | B0F829F81B4CF959002A0A6F /* AppDelegate.h */, 133 | B0F829F91B4CF959002A0A6F /* AppDelegate.m */, 134 | B0F829FA1B4CF959002A0A6F /* Common.h */, 135 | B0F829D01B4CF8C3002A0A6F /* Info.plist */, 136 | B0F829D11B4CF8C3002A0A6F /* main.m */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | B0F829EB1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | B0F829EE1B4CF8C3002A0A6F /* UITableViewCell_______Tests.m */, 145 | B0F829EC1B4CF8C3002A0A6F /* Supporting Files */, 146 | ); 147 | path = "UITableViewCell-展开查看更多Tests"; 148 | sourceTree = ""; 149 | }; 150 | B0F829EC1B4CF8C3002A0A6F /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | B0F829ED1B4CF8C3002A0A6F /* Info.plist */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | B0F829FC1B4CF960002A0A6F /* Classes */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | B0F829FD1B4CF960002A0A6F /* Controller */, 162 | B0F82A001B4CF960002A0A6F /* Model */, 163 | B0F82A031B4CF960002A0A6F /* View */, 164 | ); 165 | path = Classes; 166 | sourceTree = ""; 167 | }; 168 | B0F829FD1B4CF960002A0A6F /* Controller */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | B0F829FE1B4CF960002A0A6F /* MainViewController.h */, 172 | B0F829FF1B4CF960002A0A6F /* MainViewController.m */, 173 | ); 174 | path = Controller; 175 | sourceTree = ""; 176 | }; 177 | B0F82A001B4CF960002A0A6F /* Model */ = { 178 | isa = PBXGroup; 179 | children = ( 180 | B0F82A011B4CF960002A0A6F /* MCCommnetModel.h */, 181 | B0F82A021B4CF960002A0A6F /* MCCommnetModel.m */, 182 | ); 183 | path = Model; 184 | sourceTree = ""; 185 | }; 186 | B0F82A031B4CF960002A0A6F /* View */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | B0F82A041B4CF960002A0A6F /* MCCommentCell.h */, 190 | B0F82A051B4CF960002A0A6F /* MCCommentCell.m */, 191 | ); 192 | path = View; 193 | sourceTree = ""; 194 | }; 195 | B0F82A091B4CF982002A0A6F /* lib */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | B0F82A0A1B4CF982002A0A6F /* Masonry */, 199 | ); 200 | path = lib; 201 | sourceTree = ""; 202 | }; 203 | B0F82A0A1B4CF982002A0A6F /* Masonry */ = { 204 | isa = PBXGroup; 205 | children = ( 206 | B0F82A0B1B4CF982002A0A6F /* Info.plist */, 207 | B0F82A0C1B4CF982002A0A6F /* MASCompositeConstraint.h */, 208 | B0F82A0D1B4CF982002A0A6F /* MASCompositeConstraint.m */, 209 | B0F82A0E1B4CF982002A0A6F /* MASConstraint+Private.h */, 210 | B0F82A0F1B4CF982002A0A6F /* MASConstraint.h */, 211 | B0F82A101B4CF982002A0A6F /* MASConstraint.m */, 212 | B0F82A111B4CF982002A0A6F /* MASConstraintMaker.h */, 213 | B0F82A121B4CF982002A0A6F /* MASConstraintMaker.m */, 214 | B0F82A131B4CF982002A0A6F /* MASLayoutConstraint.h */, 215 | B0F82A141B4CF982002A0A6F /* MASLayoutConstraint.m */, 216 | B0F82A151B4CF982002A0A6F /* Masonry.h */, 217 | B0F82A161B4CF982002A0A6F /* MASUtilities.h */, 218 | B0F82A171B4CF982002A0A6F /* MASViewAttribute.h */, 219 | B0F82A181B4CF982002A0A6F /* MASViewAttribute.m */, 220 | B0F82A191B4CF982002A0A6F /* MASViewConstraint.h */, 221 | B0F82A1A1B4CF982002A0A6F /* MASViewConstraint.m */, 222 | B0F82A1B1B4CF982002A0A6F /* NSArray+MASAdditions.h */, 223 | B0F82A1C1B4CF982002A0A6F /* NSArray+MASAdditions.m */, 224 | B0F82A1D1B4CF982002A0A6F /* NSArray+MASShorthandAdditions.h */, 225 | B0F82A1E1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.h */, 226 | B0F82A1F1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.m */, 227 | B0F82A201B4CF982002A0A6F /* View+MASAdditions.h */, 228 | B0F82A211B4CF982002A0A6F /* View+MASAdditions.m */, 229 | B0F82A221B4CF982002A0A6F /* View+MASShorthandAdditions.h */, 230 | ); 231 | path = Masonry; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXGroup section */ 235 | 236 | /* Begin PBXNativeTarget section */ 237 | B0F829CB1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多 */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = B0F829F21B4CF8C3002A0A6F /* Build configuration list for PBXNativeTarget "UITableViewCell-展开查看更多" */; 240 | buildPhases = ( 241 | B0F829C81B4CF8C3002A0A6F /* Sources */, 242 | B0F829C91B4CF8C3002A0A6F /* Frameworks */, 243 | B0F829CA1B4CF8C3002A0A6F /* Resources */, 244 | ); 245 | buildRules = ( 246 | ); 247 | dependencies = ( 248 | ); 249 | name = "UITableViewCell-展开查看更多"; 250 | productName = "UITableViewCell-展开查看更多"; 251 | productReference = B0F829CC1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多.app */; 252 | productType = "com.apple.product-type.application"; 253 | }; 254 | B0F829E71B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests */ = { 255 | isa = PBXNativeTarget; 256 | buildConfigurationList = B0F829F51B4CF8C3002A0A6F /* Build configuration list for PBXNativeTarget "UITableViewCell-展开查看更多Tests" */; 257 | buildPhases = ( 258 | B0F829E41B4CF8C3002A0A6F /* Sources */, 259 | B0F829E51B4CF8C3002A0A6F /* Frameworks */, 260 | B0F829E61B4CF8C3002A0A6F /* Resources */, 261 | ); 262 | buildRules = ( 263 | ); 264 | dependencies = ( 265 | B0F829EA1B4CF8C3002A0A6F /* PBXTargetDependency */, 266 | ); 267 | name = "UITableViewCell-展开查看更多Tests"; 268 | productName = "UITableViewCell-展开查看更多Tests"; 269 | productReference = B0F829E81B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests.xctest */; 270 | productType = "com.apple.product-type.bundle.unit-test"; 271 | }; 272 | /* End PBXNativeTarget section */ 273 | 274 | /* Begin PBXProject section */ 275 | B0F829C41B4CF8C2002A0A6F /* Project object */ = { 276 | isa = PBXProject; 277 | attributes = { 278 | LastUpgradeCheck = 0640; 279 | ORGANIZATIONNAME = Ariel; 280 | TargetAttributes = { 281 | B0F829CB1B4CF8C3002A0A6F = { 282 | CreatedOnToolsVersion = 6.4; 283 | }; 284 | B0F829E71B4CF8C3002A0A6F = { 285 | CreatedOnToolsVersion = 6.4; 286 | TestTargetID = B0F829CB1B4CF8C3002A0A6F; 287 | }; 288 | }; 289 | }; 290 | buildConfigurationList = B0F829C71B4CF8C2002A0A6F /* Build configuration list for PBXProject "UITableViewCell-展开查看更多" */; 291 | compatibilityVersion = "Xcode 3.2"; 292 | developmentRegion = English; 293 | hasScannedForEncodings = 0; 294 | knownRegions = ( 295 | en, 296 | Base, 297 | ); 298 | mainGroup = B0F829C31B4CF8C2002A0A6F; 299 | productRefGroup = B0F829CD1B4CF8C3002A0A6F /* Products */; 300 | projectDirPath = ""; 301 | projectRoot = ""; 302 | targets = ( 303 | B0F829CB1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多 */, 304 | B0F829E71B4CF8C3002A0A6F /* UITableViewCell-展开查看更多Tests */, 305 | ); 306 | }; 307 | /* End PBXProject section */ 308 | 309 | /* Begin PBXResourcesBuildPhase section */ 310 | B0F829CA1B4CF8C3002A0A6F /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | B0F82A231B4CF982002A0A6F /* Info.plist in Resources */, 315 | B0F829E01B4CF8C3002A0A6F /* Images.xcassets in Resources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | B0F829E61B4CF8C3002A0A6F /* Resources */ = { 320 | isa = PBXResourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | ); 324 | runOnlyForDeploymentPostprocessing = 0; 325 | }; 326 | /* End PBXResourcesBuildPhase section */ 327 | 328 | /* Begin PBXSourcesBuildPhase section */ 329 | B0F829C81B4CF8C3002A0A6F /* Sources */ = { 330 | isa = PBXSourcesBuildPhase; 331 | buildActionMask = 2147483647; 332 | files = ( 333 | B0F82A2B1B4CF982002A0A6F /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 334 | B0F829FB1B4CF959002A0A6F /* AppDelegate.m in Sources */, 335 | B0F82A291B4CF982002A0A6F /* MASViewConstraint.m in Sources */, 336 | B0F82A081B4CF960002A0A6F /* MCCommentCell.m in Sources */, 337 | B0F82A061B4CF960002A0A6F /* MainViewController.m in Sources */, 338 | B0F829D21B4CF8C3002A0A6F /* main.m in Sources */, 339 | B0F82A2C1B4CF982002A0A6F /* View+MASAdditions.m in Sources */, 340 | B0F82A241B4CF982002A0A6F /* MASCompositeConstraint.m in Sources */, 341 | B0F82A281B4CF982002A0A6F /* MASViewAttribute.m in Sources */, 342 | B0F82A261B4CF982002A0A6F /* MASConstraintMaker.m in Sources */, 343 | B0F82A2A1B4CF982002A0A6F /* NSArray+MASAdditions.m in Sources */, 344 | B0F82A251B4CF982002A0A6F /* MASConstraint.m in Sources */, 345 | B0F82A271B4CF982002A0A6F /* MASLayoutConstraint.m in Sources */, 346 | B0F82A071B4CF960002A0A6F /* MCCommnetModel.m in Sources */, 347 | ); 348 | runOnlyForDeploymentPostprocessing = 0; 349 | }; 350 | B0F829E41B4CF8C3002A0A6F /* Sources */ = { 351 | isa = PBXSourcesBuildPhase; 352 | buildActionMask = 2147483647; 353 | files = ( 354 | B0F829EF1B4CF8C3002A0A6F /* UITableViewCell_______Tests.m in Sources */, 355 | ); 356 | runOnlyForDeploymentPostprocessing = 0; 357 | }; 358 | /* End PBXSourcesBuildPhase section */ 359 | 360 | /* Begin PBXTargetDependency section */ 361 | B0F829EA1B4CF8C3002A0A6F /* PBXTargetDependency */ = { 362 | isa = PBXTargetDependency; 363 | target = B0F829CB1B4CF8C3002A0A6F /* UITableViewCell-展开查看更多 */; 364 | targetProxy = B0F829E91B4CF8C3002A0A6F /* PBXContainerItemProxy */; 365 | }; 366 | /* End PBXTargetDependency section */ 367 | 368 | /* Begin XCBuildConfiguration section */ 369 | B0F829F01B4CF8C3002A0A6F /* Debug */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ALWAYS_SEARCH_USER_PATHS = NO; 373 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 374 | CLANG_CXX_LIBRARY = "libc++"; 375 | CLANG_ENABLE_MODULES = YES; 376 | CLANG_ENABLE_OBJC_ARC = YES; 377 | CLANG_WARN_BOOL_CONVERSION = YES; 378 | CLANG_WARN_CONSTANT_CONVERSION = YES; 379 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 380 | CLANG_WARN_EMPTY_BODY = YES; 381 | CLANG_WARN_ENUM_CONVERSION = YES; 382 | CLANG_WARN_INT_CONVERSION = YES; 383 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 384 | CLANG_WARN_UNREACHABLE_CODE = YES; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 387 | COPY_PHASE_STRIP = NO; 388 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_DYNAMIC_NO_PIC = NO; 392 | GCC_NO_COMMON_BLOCKS = YES; 393 | GCC_OPTIMIZATION_LEVEL = 0; 394 | GCC_PREPROCESSOR_DEFINITIONS = ( 395 | "DEBUG=1", 396 | "$(inherited)", 397 | ); 398 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 406 | MTL_ENABLE_DEBUG_INFO = YES; 407 | ONLY_ACTIVE_ARCH = YES; 408 | SDKROOT = iphoneos; 409 | }; 410 | name = Debug; 411 | }; 412 | B0F829F11B4CF8C3002A0A6F /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 417 | CLANG_CXX_LIBRARY = "libc++"; 418 | CLANG_ENABLE_MODULES = YES; 419 | CLANG_ENABLE_OBJC_ARC = YES; 420 | CLANG_WARN_BOOL_CONVERSION = YES; 421 | CLANG_WARN_CONSTANT_CONVERSION = YES; 422 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INT_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN_UNREACHABLE_CODE = YES; 428 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 429 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 430 | COPY_PHASE_STRIP = NO; 431 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 432 | ENABLE_NS_ASSERTIONS = NO; 433 | ENABLE_STRICT_OBJC_MSGSEND = YES; 434 | GCC_C_LANGUAGE_STANDARD = gnu99; 435 | GCC_NO_COMMON_BLOCKS = YES; 436 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 437 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 438 | GCC_WARN_UNDECLARED_SELECTOR = YES; 439 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 440 | GCC_WARN_UNUSED_FUNCTION = YES; 441 | GCC_WARN_UNUSED_VARIABLE = YES; 442 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 443 | MTL_ENABLE_DEBUG_INFO = NO; 444 | SDKROOT = iphoneos; 445 | VALIDATE_PRODUCT = YES; 446 | }; 447 | name = Release; 448 | }; 449 | B0F829F31B4CF8C3002A0A6F /* Debug */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 453 | INFOPLIST_FILE = "UITableViewCell-展开查看更多/Info.plist"; 454 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 455 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 456 | PRODUCT_NAME = "$(TARGET_NAME)"; 457 | }; 458 | name = Debug; 459 | }; 460 | B0F829F41B4CF8C3002A0A6F /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 464 | INFOPLIST_FILE = "UITableViewCell-展开查看更多/Info.plist"; 465 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | }; 469 | name = Release; 470 | }; 471 | B0F829F61B4CF8C3002A0A6F /* Debug */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | BUNDLE_LOADER = "$(TEST_HOST)"; 475 | FRAMEWORK_SEARCH_PATHS = ( 476 | "$(SDKROOT)/Developer/Library/Frameworks", 477 | "$(inherited)", 478 | ); 479 | GCC_PREPROCESSOR_DEFINITIONS = ( 480 | "DEBUG=1", 481 | "$(inherited)", 482 | ); 483 | INFOPLIST_FILE = "UITableViewCell-展开查看更多Tests/Info.plist"; 484 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UITableViewCell-展开查看更多.app/UITableViewCell-展开查看更多"; 487 | }; 488 | name = Debug; 489 | }; 490 | B0F829F71B4CF8C3002A0A6F /* Release */ = { 491 | isa = XCBuildConfiguration; 492 | buildSettings = { 493 | BUNDLE_LOADER = "$(TEST_HOST)"; 494 | FRAMEWORK_SEARCH_PATHS = ( 495 | "$(SDKROOT)/Developer/Library/Frameworks", 496 | "$(inherited)", 497 | ); 498 | INFOPLIST_FILE = "UITableViewCell-展开查看更多Tests/Info.plist"; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UITableViewCell-展开查看更多.app/UITableViewCell-展开查看更多"; 502 | }; 503 | name = Release; 504 | }; 505 | /* End XCBuildConfiguration section */ 506 | 507 | /* Begin XCConfigurationList section */ 508 | B0F829C71B4CF8C2002A0A6F /* Build configuration list for PBXProject "UITableViewCell-展开查看更多" */ = { 509 | isa = XCConfigurationList; 510 | buildConfigurations = ( 511 | B0F829F01B4CF8C3002A0A6F /* Debug */, 512 | B0F829F11B4CF8C3002A0A6F /* Release */, 513 | ); 514 | defaultConfigurationIsVisible = 0; 515 | defaultConfigurationName = Release; 516 | }; 517 | B0F829F21B4CF8C3002A0A6F /* Build configuration list for PBXNativeTarget "UITableViewCell-展开查看更多" */ = { 518 | isa = XCConfigurationList; 519 | buildConfigurations = ( 520 | B0F829F31B4CF8C3002A0A6F /* Debug */, 521 | B0F829F41B4CF8C3002A0A6F /* Release */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | }; 525 | B0F829F51B4CF8C3002A0A6F /* Build configuration list for PBXNativeTarget "UITableViewCell-展开查看更多Tests" */ = { 526 | isa = XCConfigurationList; 527 | buildConfigurations = ( 528 | B0F829F61B4CF8C3002A0A6F /* Debug */, 529 | B0F829F71B4CF8C3002A0A6F /* Release */, 530 | ); 531 | defaultConfigurationIsVisible = 0; 532 | }; 533 | /* End XCConfigurationList section */ 534 | }; 535 | rootObject = B0F829C41B4CF8C2002A0A6F /* Project object */; 536 | } 537 | --------------------------------------------------------------------------------