├── README.md ├── SingleLineLayoutCell.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── Sekorm.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Sekorm.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── SingleLineLayoutCell.xcscheme │ └── xcschememanagement.plist ├── SingleLineLayoutCell ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── 3.imageset │ │ ├── 3.png │ │ └── Contents.json │ ├── 4.imageset │ │ ├── 4.png │ │ └── Contents.json │ ├── 5.imageset │ │ ├── 5.png │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Main.storyboard ├── SingleLineLayoutCell │ ├── SingleLineLayoutCell.h │ ├── SingleLineLayoutCell.m │ ├── SingleLineLayoutItem.h │ └── SingleLineLayoutItem.m ├── SingleLineTextInputCell │ ├── TextInputCell.h │ ├── TextInputCell.m │ ├── TextInputItem.h │ └── TextInputItem.m ├── SingleLineTextInputVC.h ├── SingleLineTextInputVC.m ├── UIView+Frame.h ├── UIView+Frame.m ├── ViewController.h ├── ViewController.m └── main.m ├── SingleLineLayoutCellTests ├── Info.plist └── SingleLineLayoutCellTests.m └── SingleLineLayoutCellUITests ├── Info.plist └── SingleLineLayoutCellUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # SingleLineLayoutCell 2 | 3 | 4 | - 工欲善其事,必先利其器。面对各种各样的单行cell,虽然代码写起来不难,但是还是比较繁琐的,浪费时间。怎么样用一种cell直接搞定这些乱七八糟的样式,实现快速高效的实现。详情请看demo源码,以下是效果图以及使用方法。欢迎各位提出建议,指导,star。 5 | 6 | 7 | ### 效果图 8 | 9 | ![1.gif](http://upload-images.jianshu.io/upload_images/1338042-2cda6fa6ebb0ec57.gif?imageMogr2/auto-orient/strip) 10 | 11 | 12 | ### 示例用法 13 | 14 | //弹窗,标题,子标题,图标,右侧箭头 15 | { 16 | SingleLineLayoutItem *item0 = [SingleLineLayoutItem itemWithTitle:@"弹窗" subtitle:@"subtitle" icon:@"3" rightType:SingleLineItemRightTypeArrow]; 17 | item0.iconWidth = 30; 18 | item0.operation = ^{ 19 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"It is so cool" message:@"Hello World !!! " delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; 20 | [alertView show]; 21 | }; 22 | } 23 | 24 | //push,标题,右侧箭头 25 | { 26 | SingleLineLayoutItem *item1 = [SingleLineLayoutItem itemWithTitle:@"push到下一控制器" rightType:SingleLineItemRightTypeArrow]; 27 | __weak typeof(self) weakSelf = self; 28 | item1.operation = ^{ 29 | UIViewController *vc = [[UIViewController alloc] init]; 30 | vc.view.backgroundColor = [UIColor cyanColor]; 31 | [weakSelf.navigationController pushViewController:vc animated:YES]; 32 | }; 33 | } 34 | 35 | //标题,子标题,图标,右侧自定义视图为UIImageView 36 | { 37 | SingleLineLayoutItem *item2 = [SingleLineLayoutItem itemWithTitle:@"标题2" subtitle:@"the subtitle length is so long . oh my god" icon:@"4" rightType:SingleLineItemRightTypeCustomView]; 38 | item2.iconWidth = 30; 39 | UIImageView *icon = [[UIImageView alloc] init]; 40 | icon.image = [UIImage imageNamed:@"4"]; 41 | icon.size = CGSizeMake(30, 30); 42 | item2.rightView = icon; 43 | [_dataArray addObject:item2]; 44 | } 45 | 46 | //标题,右侧TypeCheck 47 | { 48 | SingleLineLayoutItem *item3 = [SingleLineLayoutItem itemWithTitle:@"这个标题有点长。真的有点长" rightType:SingleLineItemRightTypeCheck]; 49 | [_dataArray addObject:item3]; 50 | } 51 | 52 | //标题,子标题,图标,右侧箭头,右侧自定义视图为UILabel 53 | { 54 | SingleLineLayoutItem *item4 = [SingleLineLayoutItem itemWithTitle:@"我的收藏(99)" subtitle:@"详细信息" icon:@"" rightType:SingleLineItemRightTypeArrowAndCustomView]; 55 | UILabel *rightLabel = [[UILabel alloc] init]; 56 | rightLabel.font = [UIFont systemFontOfSize:13]; 57 | rightLabel.text = @"右侧自定义的视图"; 58 | rightLabel.textColor = [UIColor orangeColor]; 59 | [rightLabel sizeToFit]; 60 | item4.rightView = rightLabel; 61 | } 62 | 63 | //带富文本的标题,子标题,右侧自定义视图为UISwitch 64 | { 65 | SingleLineLayoutItem *item5 = [SingleLineLayoutItem itemWithTitle:@"我的消息(5)" subtitle:@"详细信息" rightType:SingleLineItemRightTypeCustomView]; 66 | item5.titleAttributes = @{NSForegroundColorAttributeName : [UIColor redColor]}; 67 | item5.subTitleAttributes = @{NSForegroundColorAttributeName : [UIColor cyanColor]}; 68 | item5.rightView = [[UISwitch alloc] init]; 69 | } 70 | 71 | 72 | --- 73 | 74 | # TextInputCell 75 | 76 | ![2.gif](http://upload-images.jianshu.io/upload_images/1338042-76f2e0c1adcdc839.gif?imageMogr2/auto-orient/strip) 77 | 78 | ### 示例用法 79 | 80 | TextInputItem *receiverItem = [TextInputItem textInputItemWithPlaceholder:@"请输入收货人姓名" text:nil]; 81 | 82 | TextInputItem *phoneItem = [TextInputItem textInputItemWithWithTitle:@"手机号: " Placeholder:@"请输入11位手机号" text:@"13000000000"]; 83 | //设置弹出键盘的样式 84 | phoneItem.keyboardType = UIKeyboardTypeNumberPad; 85 | 86 | TextInputItem *detailAddressItem = [TextInputItem textInputItemWithTitle:@"详细地址: " Placeholder:@"请输入详细地址" textInputType:TextInputTextView]; 87 | -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B42A91001EBAC7ED00109EC5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A90FF1EBAC7ED00109EC5 /* main.m */; }; 11 | B42A91031EBAC7ED00109EC5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A91021EBAC7ED00109EC5 /* AppDelegate.m */; }; 12 | B42A91061EBAC7ED00109EC5 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A91051EBAC7ED00109EC5 /* ViewController.m */; }; 13 | B42A910B1EBAC7ED00109EC5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B42A910A1EBAC7ED00109EC5 /* Assets.xcassets */; }; 14 | B42A910E1EBAC7ED00109EC5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B42A910C1EBAC7ED00109EC5 /* LaunchScreen.storyboard */; }; 15 | B42A91191EBAC7ED00109EC5 /* SingleLineLayoutCellTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A91181EBAC7ED00109EC5 /* SingleLineLayoutCellTests.m */; }; 16 | B42A91241EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A91231EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.m */; }; 17 | B42A913D1EBAC89700109EC5 /* SingleLineLayoutCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A913A1EBAC89700109EC5 /* SingleLineLayoutCell.m */; }; 18 | B42A913E1EBAC89700109EC5 /* SingleLineLayoutItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A913C1EBAC89700109EC5 /* SingleLineLayoutItem.m */; }; 19 | B42A91411EBAC8DD00109EC5 /* UIView+Frame.m in Sources */ = {isa = PBXBuildFile; fileRef = B42A91401EBAC8DD00109EC5 /* UIView+Frame.m */; }; 20 | B476DF481EC15DB700F0A048 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B476DF471EC15DB700F0A048 /* Main.storyboard */; }; 21 | B476DF4C1EC1627D00F0A048 /* TextInputCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B476DF4B1EC1627D00F0A048 /* TextInputCell.m */; }; 22 | B476DF4F1EC1628200F0A048 /* TextInputItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B476DF4E1EC1628200F0A048 /* TextInputItem.m */; }; 23 | B476DF521EC1668600F0A048 /* SingleLineTextInputVC.m in Sources */ = {isa = PBXBuildFile; fileRef = B476DF511EC1668600F0A048 /* SingleLineTextInputVC.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | B42A91151EBAC7ED00109EC5 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = B42A90F31EBAC7ED00109EC5 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = B42A90FA1EBAC7ED00109EC5; 32 | remoteInfo = SingleLineLayoutCell; 33 | }; 34 | B42A91201EBAC7ED00109EC5 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = B42A90F31EBAC7ED00109EC5 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = B42A90FA1EBAC7ED00109EC5; 39 | remoteInfo = SingleLineLayoutCell; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | B42A90FB1EBAC7ED00109EC5 /* SingleLineLayoutCell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SingleLineLayoutCell.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | B42A90FF1EBAC7ED00109EC5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | B42A91011EBAC7ED00109EC5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 47 | B42A91021EBAC7ED00109EC5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 48 | B42A91041EBAC7ED00109EC5 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 49 | B42A91051EBAC7ED00109EC5 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 50 | B42A910A1EBAC7ED00109EC5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | B42A910D1EBAC7ED00109EC5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | B42A910F1EBAC7ED00109EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | B42A91141EBAC7ED00109EC5 /* SingleLineLayoutCellTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SingleLineLayoutCellTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | B42A91181EBAC7ED00109EC5 /* SingleLineLayoutCellTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SingleLineLayoutCellTests.m; sourceTree = ""; }; 55 | B42A911A1EBAC7ED00109EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | B42A911F1EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SingleLineLayoutCellUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | B42A91231EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SingleLineLayoutCellUITests.m; sourceTree = ""; }; 58 | B42A91251EBAC7ED00109EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | B42A91391EBAC89700109EC5 /* SingleLineLayoutCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleLineLayoutCell.h; sourceTree = ""; }; 60 | B42A913A1EBAC89700109EC5 /* SingleLineLayoutCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SingleLineLayoutCell.m; sourceTree = ""; }; 61 | B42A913B1EBAC89700109EC5 /* SingleLineLayoutItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleLineLayoutItem.h; sourceTree = ""; }; 62 | B42A913C1EBAC89700109EC5 /* SingleLineLayoutItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SingleLineLayoutItem.m; sourceTree = ""; }; 63 | B42A913F1EBAC8DD00109EC5 /* UIView+Frame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Frame.h"; sourceTree = ""; }; 64 | B42A91401EBAC8DD00109EC5 /* UIView+Frame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Frame.m"; sourceTree = ""; }; 65 | B476DF471EC15DB700F0A048 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 66 | B476DF4A1EC1627D00F0A048 /* TextInputCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputCell.h; sourceTree = ""; }; 67 | B476DF4B1EC1627D00F0A048 /* TextInputCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextInputCell.m; sourceTree = ""; }; 68 | B476DF4D1EC1628200F0A048 /* TextInputItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputItem.h; sourceTree = ""; }; 69 | B476DF4E1EC1628200F0A048 /* TextInputItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextInputItem.m; sourceTree = ""; }; 70 | B476DF501EC1668600F0A048 /* SingleLineTextInputVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleLineTextInputVC.h; sourceTree = ""; }; 71 | B476DF511EC1668600F0A048 /* SingleLineTextInputVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SingleLineTextInputVC.m; sourceTree = ""; }; 72 | /* End PBXFileReference section */ 73 | 74 | /* Begin PBXFrameworksBuildPhase section */ 75 | B42A90F81EBAC7ED00109EC5 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | B42A91111EBAC7ED00109EC5 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | B42A911C1EBAC7ED00109EC5 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | B42A90F21EBAC7ED00109EC5 = { 100 | isa = PBXGroup; 101 | children = ( 102 | B42A90FD1EBAC7ED00109EC5 /* SingleLineLayoutCell */, 103 | B42A91171EBAC7ED00109EC5 /* SingleLineLayoutCellTests */, 104 | B42A91221EBAC7ED00109EC5 /* SingleLineLayoutCellUITests */, 105 | B42A90FC1EBAC7ED00109EC5 /* Products */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | B42A90FC1EBAC7ED00109EC5 /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | B42A90FB1EBAC7ED00109EC5 /* SingleLineLayoutCell.app */, 113 | B42A91141EBAC7ED00109EC5 /* SingleLineLayoutCellTests.xctest */, 114 | B42A911F1EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.xctest */, 115 | ); 116 | name = Products; 117 | sourceTree = ""; 118 | }; 119 | B42A90FD1EBAC7ED00109EC5 /* SingleLineLayoutCell */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | B476DF491EC1627400F0A048 /* SingleLineTextInputCell */, 123 | B42A91381EBAC89700109EC5 /* SingleLineLayoutCell */, 124 | B42A91041EBAC7ED00109EC5 /* ViewController.h */, 125 | B42A91051EBAC7ED00109EC5 /* ViewController.m */, 126 | B476DF501EC1668600F0A048 /* SingleLineTextInputVC.h */, 127 | B476DF511EC1668600F0A048 /* SingleLineTextInputVC.m */, 128 | B42A910A1EBAC7ED00109EC5 /* Assets.xcassets */, 129 | B42A910C1EBAC7ED00109EC5 /* LaunchScreen.storyboard */, 130 | B476DF471EC15DB700F0A048 /* Main.storyboard */, 131 | B42A913F1EBAC8DD00109EC5 /* UIView+Frame.h */, 132 | B42A91401EBAC8DD00109EC5 /* UIView+Frame.m */, 133 | B42A910F1EBAC7ED00109EC5 /* Info.plist */, 134 | B42A90FE1EBAC7ED00109EC5 /* Supporting Files */, 135 | ); 136 | path = SingleLineLayoutCell; 137 | sourceTree = ""; 138 | }; 139 | B42A90FE1EBAC7ED00109EC5 /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | B42A91011EBAC7ED00109EC5 /* AppDelegate.h */, 143 | B42A91021EBAC7ED00109EC5 /* AppDelegate.m */, 144 | B42A90FF1EBAC7ED00109EC5 /* main.m */, 145 | ); 146 | name = "Supporting Files"; 147 | sourceTree = ""; 148 | }; 149 | B42A91171EBAC7ED00109EC5 /* SingleLineLayoutCellTests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | B42A91181EBAC7ED00109EC5 /* SingleLineLayoutCellTests.m */, 153 | B42A911A1EBAC7ED00109EC5 /* Info.plist */, 154 | ); 155 | path = SingleLineLayoutCellTests; 156 | sourceTree = ""; 157 | }; 158 | B42A91221EBAC7ED00109EC5 /* SingleLineLayoutCellUITests */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | B42A91231EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.m */, 162 | B42A91251EBAC7ED00109EC5 /* Info.plist */, 163 | ); 164 | path = SingleLineLayoutCellUITests; 165 | sourceTree = ""; 166 | }; 167 | B42A91381EBAC89700109EC5 /* SingleLineLayoutCell */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | B42A91391EBAC89700109EC5 /* SingleLineLayoutCell.h */, 171 | B42A913A1EBAC89700109EC5 /* SingleLineLayoutCell.m */, 172 | B42A913B1EBAC89700109EC5 /* SingleLineLayoutItem.h */, 173 | B42A913C1EBAC89700109EC5 /* SingleLineLayoutItem.m */, 174 | ); 175 | path = SingleLineLayoutCell; 176 | sourceTree = ""; 177 | }; 178 | B476DF491EC1627400F0A048 /* SingleLineTextInputCell */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | B476DF4D1EC1628200F0A048 /* TextInputItem.h */, 182 | B476DF4E1EC1628200F0A048 /* TextInputItem.m */, 183 | B476DF4A1EC1627D00F0A048 /* TextInputCell.h */, 184 | B476DF4B1EC1627D00F0A048 /* TextInputCell.m */, 185 | ); 186 | path = SingleLineTextInputCell; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXGroup section */ 190 | 191 | /* Begin PBXNativeTarget section */ 192 | B42A90FA1EBAC7ED00109EC5 /* SingleLineLayoutCell */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = B42A91281EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCell" */; 195 | buildPhases = ( 196 | B42A90F71EBAC7ED00109EC5 /* Sources */, 197 | B42A90F81EBAC7ED00109EC5 /* Frameworks */, 198 | B42A90F91EBAC7ED00109EC5 /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | ); 204 | name = SingleLineLayoutCell; 205 | productName = SingleLineLayoutCell; 206 | productReference = B42A90FB1EBAC7ED00109EC5 /* SingleLineLayoutCell.app */; 207 | productType = "com.apple.product-type.application"; 208 | }; 209 | B42A91131EBAC7ED00109EC5 /* SingleLineLayoutCellTests */ = { 210 | isa = PBXNativeTarget; 211 | buildConfigurationList = B42A912B1EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCellTests" */; 212 | buildPhases = ( 213 | B42A91101EBAC7ED00109EC5 /* Sources */, 214 | B42A91111EBAC7ED00109EC5 /* Frameworks */, 215 | B42A91121EBAC7ED00109EC5 /* Resources */, 216 | ); 217 | buildRules = ( 218 | ); 219 | dependencies = ( 220 | B42A91161EBAC7ED00109EC5 /* PBXTargetDependency */, 221 | ); 222 | name = SingleLineLayoutCellTests; 223 | productName = SingleLineLayoutCellTests; 224 | productReference = B42A91141EBAC7ED00109EC5 /* SingleLineLayoutCellTests.xctest */; 225 | productType = "com.apple.product-type.bundle.unit-test"; 226 | }; 227 | B42A911E1EBAC7ED00109EC5 /* SingleLineLayoutCellUITests */ = { 228 | isa = PBXNativeTarget; 229 | buildConfigurationList = B42A912E1EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCellUITests" */; 230 | buildPhases = ( 231 | B42A911B1EBAC7ED00109EC5 /* Sources */, 232 | B42A911C1EBAC7ED00109EC5 /* Frameworks */, 233 | B42A911D1EBAC7ED00109EC5 /* Resources */, 234 | ); 235 | buildRules = ( 236 | ); 237 | dependencies = ( 238 | B42A91211EBAC7ED00109EC5 /* PBXTargetDependency */, 239 | ); 240 | name = SingleLineLayoutCellUITests; 241 | productName = SingleLineLayoutCellUITests; 242 | productReference = B42A911F1EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.xctest */; 243 | productType = "com.apple.product-type.bundle.ui-testing"; 244 | }; 245 | /* End PBXNativeTarget section */ 246 | 247 | /* Begin PBXProject section */ 248 | B42A90F31EBAC7ED00109EC5 /* Project object */ = { 249 | isa = PBXProject; 250 | attributes = { 251 | LastUpgradeCheck = 0810; 252 | ORGANIZATIONNAME = YL; 253 | TargetAttributes = { 254 | B42A90FA1EBAC7ED00109EC5 = { 255 | CreatedOnToolsVersion = 8.1; 256 | DevelopmentTeam = W55448EFBF; 257 | ProvisioningStyle = Automatic; 258 | }; 259 | B42A91131EBAC7ED00109EC5 = { 260 | CreatedOnToolsVersion = 8.1; 261 | DevelopmentTeam = W55448EFBF; 262 | ProvisioningStyle = Automatic; 263 | TestTargetID = B42A90FA1EBAC7ED00109EC5; 264 | }; 265 | B42A911E1EBAC7ED00109EC5 = { 266 | CreatedOnToolsVersion = 8.1; 267 | DevelopmentTeam = W55448EFBF; 268 | ProvisioningStyle = Automatic; 269 | TestTargetID = B42A90FA1EBAC7ED00109EC5; 270 | }; 271 | }; 272 | }; 273 | buildConfigurationList = B42A90F61EBAC7ED00109EC5 /* Build configuration list for PBXProject "SingleLineLayoutCell" */; 274 | compatibilityVersion = "Xcode 3.2"; 275 | developmentRegion = English; 276 | hasScannedForEncodings = 0; 277 | knownRegions = ( 278 | en, 279 | Base, 280 | ); 281 | mainGroup = B42A90F21EBAC7ED00109EC5; 282 | productRefGroup = B42A90FC1EBAC7ED00109EC5 /* Products */; 283 | projectDirPath = ""; 284 | projectRoot = ""; 285 | targets = ( 286 | B42A90FA1EBAC7ED00109EC5 /* SingleLineLayoutCell */, 287 | B42A91131EBAC7ED00109EC5 /* SingleLineLayoutCellTests */, 288 | B42A911E1EBAC7ED00109EC5 /* SingleLineLayoutCellUITests */, 289 | ); 290 | }; 291 | /* End PBXProject section */ 292 | 293 | /* Begin PBXResourcesBuildPhase section */ 294 | B42A90F91EBAC7ED00109EC5 /* Resources */ = { 295 | isa = PBXResourcesBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | B42A910E1EBAC7ED00109EC5 /* LaunchScreen.storyboard in Resources */, 299 | B476DF481EC15DB700F0A048 /* Main.storyboard in Resources */, 300 | B42A910B1EBAC7ED00109EC5 /* Assets.xcassets in Resources */, 301 | ); 302 | runOnlyForDeploymentPostprocessing = 0; 303 | }; 304 | B42A91121EBAC7ED00109EC5 /* Resources */ = { 305 | isa = PBXResourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | B42A911D1EBAC7ED00109EC5 /* Resources */ = { 312 | isa = PBXResourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | /* End PBXResourcesBuildPhase section */ 319 | 320 | /* Begin PBXSourcesBuildPhase section */ 321 | B42A90F71EBAC7ED00109EC5 /* Sources */ = { 322 | isa = PBXSourcesBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | B476DF521EC1668600F0A048 /* SingleLineTextInputVC.m in Sources */, 326 | B42A91411EBAC8DD00109EC5 /* UIView+Frame.m in Sources */, 327 | B42A91061EBAC7ED00109EC5 /* ViewController.m in Sources */, 328 | B476DF4C1EC1627D00F0A048 /* TextInputCell.m in Sources */, 329 | B42A913D1EBAC89700109EC5 /* SingleLineLayoutCell.m in Sources */, 330 | B42A91031EBAC7ED00109EC5 /* AppDelegate.m in Sources */, 331 | B42A91001EBAC7ED00109EC5 /* main.m in Sources */, 332 | B476DF4F1EC1628200F0A048 /* TextInputItem.m in Sources */, 333 | B42A913E1EBAC89700109EC5 /* SingleLineLayoutItem.m in Sources */, 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | }; 337 | B42A91101EBAC7ED00109EC5 /* Sources */ = { 338 | isa = PBXSourcesBuildPhase; 339 | buildActionMask = 2147483647; 340 | files = ( 341 | B42A91191EBAC7ED00109EC5 /* SingleLineLayoutCellTests.m in Sources */, 342 | ); 343 | runOnlyForDeploymentPostprocessing = 0; 344 | }; 345 | B42A911B1EBAC7ED00109EC5 /* Sources */ = { 346 | isa = PBXSourcesBuildPhase; 347 | buildActionMask = 2147483647; 348 | files = ( 349 | B42A91241EBAC7ED00109EC5 /* SingleLineLayoutCellUITests.m in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | /* End PBXSourcesBuildPhase section */ 354 | 355 | /* Begin PBXTargetDependency section */ 356 | B42A91161EBAC7ED00109EC5 /* PBXTargetDependency */ = { 357 | isa = PBXTargetDependency; 358 | target = B42A90FA1EBAC7ED00109EC5 /* SingleLineLayoutCell */; 359 | targetProxy = B42A91151EBAC7ED00109EC5 /* PBXContainerItemProxy */; 360 | }; 361 | B42A91211EBAC7ED00109EC5 /* PBXTargetDependency */ = { 362 | isa = PBXTargetDependency; 363 | target = B42A90FA1EBAC7ED00109EC5 /* SingleLineLayoutCell */; 364 | targetProxy = B42A91201EBAC7ED00109EC5 /* PBXContainerItemProxy */; 365 | }; 366 | /* End PBXTargetDependency section */ 367 | 368 | /* Begin PBXVariantGroup section */ 369 | B42A910C1EBAC7ED00109EC5 /* LaunchScreen.storyboard */ = { 370 | isa = PBXVariantGroup; 371 | children = ( 372 | B42A910D1EBAC7ED00109EC5 /* Base */, 373 | ); 374 | name = LaunchScreen.storyboard; 375 | sourceTree = ""; 376 | }; 377 | /* End PBXVariantGroup section */ 378 | 379 | /* Begin XCBuildConfiguration section */ 380 | B42A91261EBAC7ED00109EC5 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ALWAYS_SEARCH_USER_PATHS = NO; 384 | CLANG_ANALYZER_NONNULL = YES; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = dwarf; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | ENABLE_TESTABILITY = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_DYNAMIC_NO_PIC = NO; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_OPTIMIZATION_LEVEL = 0; 410 | GCC_PREPROCESSOR_DEFINITIONS = ( 411 | "DEBUG=1", 412 | "$(inherited)", 413 | ); 414 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 415 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 416 | GCC_WARN_UNDECLARED_SELECTOR = YES; 417 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 418 | GCC_WARN_UNUSED_FUNCTION = YES; 419 | GCC_WARN_UNUSED_VARIABLE = YES; 420 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 421 | MTL_ENABLE_DEBUG_INFO = YES; 422 | ONLY_ACTIVE_ARCH = YES; 423 | SDKROOT = iphoneos; 424 | }; 425 | name = Debug; 426 | }; 427 | B42A91271EBAC7ED00109EC5 /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | ALWAYS_SEARCH_USER_PATHS = NO; 431 | CLANG_ANALYZER_NONNULL = YES; 432 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 433 | CLANG_CXX_LIBRARY = "libc++"; 434 | CLANG_ENABLE_MODULES = YES; 435 | CLANG_ENABLE_OBJC_ARC = YES; 436 | CLANG_WARN_BOOL_CONVERSION = YES; 437 | CLANG_WARN_CONSTANT_CONVERSION = YES; 438 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 439 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 440 | CLANG_WARN_EMPTY_BODY = YES; 441 | CLANG_WARN_ENUM_CONVERSION = YES; 442 | CLANG_WARN_INFINITE_RECURSION = YES; 443 | CLANG_WARN_INT_CONVERSION = YES; 444 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 445 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 446 | CLANG_WARN_UNREACHABLE_CODE = YES; 447 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 448 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 449 | COPY_PHASE_STRIP = NO; 450 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 451 | ENABLE_NS_ASSERTIONS = NO; 452 | ENABLE_STRICT_OBJC_MSGSEND = YES; 453 | GCC_C_LANGUAGE_STANDARD = gnu99; 454 | GCC_NO_COMMON_BLOCKS = YES; 455 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 456 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 457 | GCC_WARN_UNDECLARED_SELECTOR = YES; 458 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 459 | GCC_WARN_UNUSED_FUNCTION = YES; 460 | GCC_WARN_UNUSED_VARIABLE = YES; 461 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 462 | MTL_ENABLE_DEBUG_INFO = NO; 463 | SDKROOT = iphoneos; 464 | VALIDATE_PRODUCT = YES; 465 | }; 466 | name = Release; 467 | }; 468 | B42A91291EBAC7ED00109EC5 /* Debug */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 472 | DEVELOPMENT_TEAM = W55448EFBF; 473 | INFOPLIST_FILE = SingleLineLayoutCell/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 475 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCell; 476 | PRODUCT_NAME = "$(TARGET_NAME)"; 477 | }; 478 | name = Debug; 479 | }; 480 | B42A912A1EBAC7ED00109EC5 /* Release */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 484 | DEVELOPMENT_TEAM = W55448EFBF; 485 | INFOPLIST_FILE = SingleLineLayoutCell/Info.plist; 486 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 487 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCell; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | }; 490 | name = Release; 491 | }; 492 | B42A912C1EBAC7ED00109EC5 /* Debug */ = { 493 | isa = XCBuildConfiguration; 494 | buildSettings = { 495 | BUNDLE_LOADER = "$(TEST_HOST)"; 496 | DEVELOPMENT_TEAM = W55448EFBF; 497 | INFOPLIST_FILE = SingleLineLayoutCellTests/Info.plist; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCellTests; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SingleLineLayoutCell.app/SingleLineLayoutCell"; 502 | }; 503 | name = Debug; 504 | }; 505 | B42A912D1EBAC7ED00109EC5 /* Release */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | BUNDLE_LOADER = "$(TEST_HOST)"; 509 | DEVELOPMENT_TEAM = W55448EFBF; 510 | INFOPLIST_FILE = SingleLineLayoutCellTests/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCellTests; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SingleLineLayoutCell.app/SingleLineLayoutCell"; 515 | }; 516 | name = Release; 517 | }; 518 | B42A912F1EBAC7ED00109EC5 /* Debug */ = { 519 | isa = XCBuildConfiguration; 520 | buildSettings = { 521 | DEVELOPMENT_TEAM = W55448EFBF; 522 | INFOPLIST_FILE = SingleLineLayoutCellUITests/Info.plist; 523 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 524 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCellUITests; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | TEST_TARGET_NAME = SingleLineLayoutCell; 527 | }; 528 | name = Debug; 529 | }; 530 | B42A91301EBAC7ED00109EC5 /* Release */ = { 531 | isa = XCBuildConfiguration; 532 | buildSettings = { 533 | DEVELOPMENT_TEAM = W55448EFBF; 534 | INFOPLIST_FILE = SingleLineLayoutCellUITests/Info.plist; 535 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 536 | PRODUCT_BUNDLE_IDENTIFIER = com.yeliang.SingleLineLayoutCellUITests; 537 | PRODUCT_NAME = "$(TARGET_NAME)"; 538 | TEST_TARGET_NAME = SingleLineLayoutCell; 539 | }; 540 | name = Release; 541 | }; 542 | /* End XCBuildConfiguration section */ 543 | 544 | /* Begin XCConfigurationList section */ 545 | B42A90F61EBAC7ED00109EC5 /* Build configuration list for PBXProject "SingleLineLayoutCell" */ = { 546 | isa = XCConfigurationList; 547 | buildConfigurations = ( 548 | B42A91261EBAC7ED00109EC5 /* Debug */, 549 | B42A91271EBAC7ED00109EC5 /* Release */, 550 | ); 551 | defaultConfigurationIsVisible = 0; 552 | defaultConfigurationName = Release; 553 | }; 554 | B42A91281EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCell" */ = { 555 | isa = XCConfigurationList; 556 | buildConfigurations = ( 557 | B42A91291EBAC7ED00109EC5 /* Debug */, 558 | B42A912A1EBAC7ED00109EC5 /* Release */, 559 | ); 560 | defaultConfigurationIsVisible = 0; 561 | defaultConfigurationName = Release; 562 | }; 563 | B42A912B1EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCellTests" */ = { 564 | isa = XCConfigurationList; 565 | buildConfigurations = ( 566 | B42A912C1EBAC7ED00109EC5 /* Debug */, 567 | B42A912D1EBAC7ED00109EC5 /* Release */, 568 | ); 569 | defaultConfigurationIsVisible = 0; 570 | defaultConfigurationName = Release; 571 | }; 572 | B42A912E1EBAC7ED00109EC5 /* Build configuration list for PBXNativeTarget "SingleLineLayoutCellUITests" */ = { 573 | isa = XCConfigurationList; 574 | buildConfigurations = ( 575 | B42A912F1EBAC7ED00109EC5 /* Debug */, 576 | B42A91301EBAC7ED00109EC5 /* Release */, 577 | ); 578 | defaultConfigurationIsVisible = 0; 579 | defaultConfigurationName = Release; 580 | }; 581 | /* End XCConfigurationList section */ 582 | }; 583 | rootObject = B42A90F31EBAC7ED00109EC5 /* Project object */; 584 | } 585 | -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/project.xcworkspace/xcuserdata/Sekorm.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/SingleLineLayoutCell/2d11655921a08cc7b3098cafcfae1730438091fe/SingleLineLayoutCell.xcodeproj/project.xcworkspace/xcuserdata/Sekorm.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcschemes/SingleLineLayoutCell.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /SingleLineLayoutCell.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SingleLineLayoutCell.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B42A90FA1EBAC7ED00109EC5 16 | 17 | primary 18 | 19 | 20 | B42A91131EBAC7ED00109EC5 21 | 22 | primary 23 | 24 | 25 | B42A911E1EBAC7ED00109EC5 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. 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 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/3.imageset/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/SingleLineLayoutCell/2d11655921a08cc7b3098cafcfae1730438091fe/SingleLineLayoutCell/Assets.xcassets/3.imageset/3.png -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "3.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/4.imageset/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/SingleLineLayoutCell/2d11655921a08cc7b3098cafcfae1730438091fe/SingleLineLayoutCell/Assets.xcassets/4.imageset/4.png -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "4.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/5.imageset/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/SingleLineLayoutCell/2d11655921a08cc7b3098cafcfae1730438091fe/SingleLineLayoutCell/Assets.xcassets/5.imageset/5.png -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "5.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /SingleLineLayoutCell/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SingleLineLayoutCell/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineLayoutCell/SingleLineLayoutCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineLayoutCell.h 3 | // 4 | // 5 | 6 | #import 7 | 8 | @class SingleLineLayoutItem; 9 | 10 | @interface SingleLineLayoutCell : UITableViewCell 11 | @property (nonatomic,strong) SingleLineLayoutItem *recordSingleLineItem; 12 | @end 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineLayoutCell/SingleLineLayoutCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineLayoutCell.m 3 | // 4 | // 5 | #import 6 | #import "SingleLineLayoutCell.h" 7 | #import "SingleLineLayoutItem.h" 8 | #import "UIView+Frame.h" 9 | 10 | @interface SingleLineLayoutCell () 11 | 12 | @property (strong, nonatomic) UIImageView *iconView; 13 | @property (strong, nonatomic) UILabel *titleLabel; 14 | @property (strong, nonatomic) UILabel *subTitleLabel; 15 | @property (strong, nonatomic) UIView *rightView; 16 | @end 17 | 18 | @implementation SingleLineLayoutCell 19 | 20 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 21 | 22 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 23 | [self.contentView addSubview:self.titleLabel]; 24 | self.userInteractionEnabled = YES; 25 | [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)]]; 26 | } 27 | return self; 28 | } 29 | 30 | 31 | - (void)click:(UIGestureRecognizer *)tap { 32 | 33 | if (self.recordSingleLineItem.operation) { 34 | self.recordSingleLineItem.operation(); 35 | } 36 | } 37 | 38 | - (void)setRecordSingleLineItem:(SingleLineLayoutItem *)singleLineItem { 39 | 40 | _recordSingleLineItem = singleLineItem; 41 | 42 | CGFloat contentLeft = 12.5; 43 | /*********************** 图标 ***********************/ 44 | UIImage *image = (singleLineItem.icon) ? [UIImage imageNamed:singleLineItem.icon] : nil; 45 | if(singleLineItem.icon && image) { 46 | 47 | [self.contentView addSubview:self.iconView]; 48 | self.iconView.image = image; 49 | self.iconView.contentMode = singleLineItem.iconMode; 50 | self.iconView.left = contentLeft; 51 | if (singleLineItem.iconWidth > 0) { 52 | self.iconView.size = CGSizeMake(singleLineItem.iconWidth, singleLineItem.iconWidth); 53 | }else { 54 | [self.iconView sizeToFit]; 55 | } 56 | contentLeft = self.iconView.right + singleLineItem.iconMargin; 57 | }else { 58 | [self resetSubview:_iconView]; 59 | } 60 | 61 | /*********************** 标题 ***********************/ 62 | 63 | if (singleLineItem.title && singleLineItem.titleAttributes) { 64 | self.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:singleLineItem.title attributes:singleLineItem.titleAttributes]; 65 | } else { 66 | self.titleLabel.text = singleLineItem.title; 67 | } 68 | 69 | self.titleLabel.size = [self.titleLabel sizeThatFits:CGSizeMake(self.width * 0.45, self.height)]; 70 | self.titleLabel.left = contentLeft; 71 | self.titleLabel.width = MIN(self.titleLabel.width, self.width * 0.6); 72 | contentLeft = self.titleLabel.right + 2; 73 | 74 | 75 | /*********************** 子标题 ***********************/ 76 | if (singleLineItem.subtitle) { 77 | 78 | [self.contentView addSubview:self.subTitleLabel]; 79 | if (singleLineItem.subTitleAttributes) { 80 | self.subTitleLabel.attributedText = [[NSAttributedString alloc] initWithString:singleLineItem.subtitle attributes:singleLineItem.subTitleAttributes]; 81 | }else { 82 | self.subTitleLabel.text = singleLineItem.subtitle; 83 | } 84 | [self.subTitleLabel sizeToFit]; 85 | self.subTitleLabel.left = contentLeft; 86 | self.subTitleLabel.width = MIN(self.subTitleLabel.width, self.width * 0.4); 87 | contentLeft = self.subTitleLabel.right; 88 | 89 | }else { 90 | [self resetSubview:_subTitleLabel]; 91 | } 92 | 93 | /*********************** 右侧视图 ***********************/ 94 | [_rightView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];//增加此已解决复用时候重影问题 95 | [self resetSubview:_rightView]; 96 | 97 | SingleLineItemRightType type = singleLineItem.rightType; 98 | switch (type) { 99 | case SingleLineItemRightTypeNone: 100 | self.accessoryType = UITableViewCellAccessoryNone; 101 | break; 102 | case SingleLineItemRightTypeArrow: 103 | self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 104 | break; 105 | case SingleLineItemRightTypeArrowAndCustomView: 106 | [self.contentView addSubview:self.rightView]; 107 | [self.rightView addSubview:singleLineItem.rightView]; 108 | self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 109 | break; 110 | case SingleLineItemRightTypeCheck: 111 | self.accessoryType = UITableViewCellAccessoryCheckmark; 112 | break; 113 | case SingleLineItemRightTypeCheckAndCustomView: 114 | [self.contentView addSubview:self.rightView]; 115 | [self.rightView addSubview:singleLineItem.rightView]; 116 | self.accessoryType = UITableViewCellAccessoryCheckmark; 117 | break; 118 | case SingleLineItemRightTypeCustomView: 119 | [self.contentView addSubview:self.rightView]; 120 | [self.rightView addSubview:singleLineItem.rightView]; 121 | self.accessoryType = UITableViewCellAccessoryNone; 122 | break; 123 | default: 124 | self.accessoryType = UITableViewCellAccessoryNone; 125 | break; 126 | } 127 | } 128 | 129 | - (void)setRightViewFrame { 130 | 131 | self.rightView.size = self.recordSingleLineItem.rightView.size; 132 | self.rightView.centerY = self.height * 0.5; 133 | 134 | SingleLineItemRightType type = self.recordSingleLineItem.rightType; 135 | switch (type) { 136 | 137 | case SingleLineItemRightTypeArrowAndCustomView: 138 | self.rightView.right = self.contentView.width; 139 | break; 140 | case SingleLineItemRightTypeCheckAndCustomView: 141 | self.rightView.right = self.contentView.width; 142 | break; 143 | case SingleLineItemRightTypeCustomView: 144 | self.rightView.right = self.contentView.width - 12.5; 145 | break; 146 | default: 147 | break; 148 | } 149 | } 150 | 151 | - (UIImageView *)iconView { 152 | 153 | if (!_iconView) { 154 | _iconView = [[UIImageView alloc] init]; 155 | } 156 | return _iconView; 157 | } 158 | 159 | - (UILabel *)titleLabel { 160 | 161 | if (!_titleLabel) { 162 | _titleLabel = [[UILabel alloc] init]; 163 | _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; 164 | _titleLabel.font = [UIFont systemFontOfSize:15]; 165 | } 166 | return _titleLabel; 167 | } 168 | 169 | - (UILabel *)subTitleLabel { 170 | 171 | if (!_subTitleLabel) { 172 | _subTitleLabel = [[UILabel alloc] init]; 173 | _subTitleLabel.font = [UIFont systemFontOfSize:12]; 174 | _subTitleLabel.textColor = [UIColor lightGrayColor]; 175 | } 176 | return _subTitleLabel; 177 | } 178 | 179 | - (UIView *)rightView { 180 | 181 | if (!_rightView) { 182 | _rightView = [[UIView alloc] init]; 183 | } 184 | return _rightView; 185 | } 186 | 187 | - (void)resetSubview:(UIView *)view { 188 | 189 | if (view) { 190 | [view removeFromSuperview]; 191 | view = nil; 192 | } 193 | } 194 | 195 | - (void)setSubviewCenterY:(UIView *)view { 196 | 197 | if (view) { 198 | view.centerY = self.height * 0.5; 199 | } 200 | } 201 | 202 | - (void)layoutSubviews { 203 | 204 | [super layoutSubviews]; 205 | [self setSubviewCenterY:_titleLabel]; 206 | [self setSubviewCenterY:_iconView]; 207 | [self setSubviewCenterY:_subTitleLabel]; 208 | [self setSubviewCenterY:_rightView]; 209 | if (_rightView) { 210 | [self setRightViewFrame]; 211 | } 212 | } 213 | 214 | @end 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineLayoutCell/SingleLineLayoutItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineItem.h 3 | // 4 | // 5 | 6 | #import 7 | #import 8 | 9 | typedef NS_ENUM(NSUInteger, SingleLineItemRightType) { 10 | SingleLineItemRightTypeNone = 0, 11 | SingleLineItemRightTypeArrow, 12 | SingleLineItemRightTypeArrowAndCustomView, 13 | SingleLineItemRightTypeCheck, 14 | SingleLineItemRightTypeCheckAndCustomView, 15 | SingleLineItemRightTypeCustomView, 16 | }; 17 | 18 | 19 | typedef void(^Operation)(); 20 | 21 | @interface SingleLineLayoutItem : NSObject 22 | 23 | // 图标 24 | @property (nonatomic, copy) NSString *icon; 25 | // 图标模式,默认UIViewContentModeScaleToFill 26 | @property (nonatomic, assign) UIViewContentMode iconMode; 27 | // 图标宽,默认图片大小 28 | @property (nonatomic, assign) CGFloat iconWidth; 29 | // 图标左右间距,默认8 30 | @property (nonatomic, assign) CGFloat iconMargin; 31 | 32 | // 标题 33 | @property (nonatomic, copy) NSString *title; 34 | // 标题宽,默认0 35 | @property (nonatomic, assign) CGFloat titleWidth; 36 | // 标题左边间距,默认0,设置了titleMargin,图标与标题之间的间距即为titleMargin 37 | @property (nonatomic, assign) CGFloat titleMargin; 38 | // 标题主题,默认nil 39 | @property (nonatomic, strong) NSDictionary *titleAttributes; 40 | 41 | // 子标题 42 | @property (nonatomic, copy) NSString *subtitle; 43 | // 子标题文本格式,默认NSTextAlignmentRight 44 | @property (nonatomic, assign) NSTextAlignment subtitleAlignment; 45 | // 子标题主题,默认nil 46 | @property (nonatomic, strong) NSDictionary *subTitleAttributes; 47 | 48 | // 右侧自定义视图,默认nil 49 | @property (nonatomic, strong) UIView *rightView; 50 | // 右侧视图类型 51 | @property (nonatomic, assign) SingleLineItemRightType rightType; 52 | 53 | // 表格高度,默认0 54 | @property (nonatomic, assign) CGFloat height; 55 | // 点击操作,默认nil 56 | @property (nonatomic, copy) Operation operation; 57 | 58 | + (instancetype)itemWithRightType:(SingleLineItemRightType)type; 59 | + (instancetype)itemWithSubTitle:(NSString *)subtitle rightType:(SingleLineItemRightType)type; 60 | + (instancetype)itemWithTitle:(NSString *)title rightType:(SingleLineItemRightType)type; 61 | + (instancetype)itemWithTitle:(NSString *)title subtitle:(NSString *)subtitle rightType:(SingleLineItemRightType)type; 62 | + (instancetype)itemWithTitle:(NSString *)title icon:(NSString *)icon rightType:(SingleLineItemRightType)type; 63 | + (instancetype)itemWithTitle:(NSString *)title subtitle:(NSString *)subtitle icon:(NSString *)icon rightType:(SingleLineItemRightType)type; 64 | @end 65 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineLayoutCell/SingleLineLayoutItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKSingleLineItem.m 3 | // 4 | // 5 | 6 | #import "SingleLineLayoutItem.h" 7 | 8 | @implementation SingleLineLayoutItem 9 | 10 | + (instancetype)itemWithRightType:(SingleLineItemRightType)type { 11 | return [self itemWithTitle:nil subtitle:nil icon:nil rightType:type]; 12 | } 13 | 14 | + (instancetype)itemWithSubTitle:(NSString *)subtitle rightType:(SingleLineItemRightType)type { 15 | return [self itemWithTitle:nil subtitle:subtitle icon:nil rightType:type]; 16 | } 17 | 18 | + (instancetype)itemWithTitle:(NSString *)title rightType:(SingleLineItemRightType)type { 19 | return [self itemWithTitle:title subtitle:nil icon:nil rightType:type]; 20 | } 21 | 22 | + (instancetype)itemWithTitle:(NSString *)title subtitle:(NSString *)subtitle rightType:(SingleLineItemRightType)type { 23 | return [self itemWithTitle:title subtitle:subtitle icon:nil rightType:type]; 24 | } 25 | 26 | + (instancetype)itemWithTitle:(NSString *)title icon:(NSString *)icon rightType:(SingleLineItemRightType)type { 27 | return [self itemWithTitle:title subtitle:nil icon:icon rightType:type]; 28 | } 29 | 30 | + (instancetype)itemWithTitle:(NSString *)title subtitle:(NSString *)subtitle icon:(NSString *)icon rightType:(SingleLineItemRightType)type { 31 | SingleLineLayoutItem *item = [[self alloc] init]; 32 | item.icon = icon; 33 | item.title = title; 34 | item.subtitle = subtitle; 35 | item.rightType = type; 36 | // 默认设置 37 | item.iconMode = UIViewContentModeScaleToFill; 38 | item.iconMargin = 8; 39 | item.iconWidth = 0; 40 | item.titleMargin = 0; 41 | item.subtitleAlignment = NSTextAlignmentRight; 42 | return item; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputCell/TextInputCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextInputCell.h 3 | // Copyright © 2017年 YeLiang. All rights reserved. 4 | // 5 | 6 | #import 7 | #import "TextInputItem.h" 8 | 9 | @protocol TextInputCellDelegate 10 | - (void)textInputCellTextChange:(NSString *)InputText; 11 | @end 12 | 13 | @interface TextInputCell : UITableViewCell 14 | @property (nonatomic,strong) TextInputItem *textInputItem; 15 | @property (nonatomic,weak) id delegate; 16 | @property (nonatomic,copy) void(^textInputChange)(); 17 | - (BOOL)becomeFirstResponder; 18 | @end 19 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputCell/TextInputCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TextInputCell.m 3 | // Copyright © 2017年 YeLiang. All rights reserved. 4 | // 5 | 6 | #import "TextInputCell.h" 7 | #import "UIView+Frame.h" 8 | 9 | #define kContentLeftAndRightMargin 12.5 10 | 11 | @interface TextInputCell () 12 | @property (nonatomic,strong) UIView *textInputView; 13 | @property (nonatomic,strong) UILabel *titleLabel; 14 | @end 15 | 16 | @implementation TextInputCell 17 | 18 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 19 | 20 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 21 | [self.contentView addSubview:self.titleLabel]; 22 | } 23 | return self; 24 | } 25 | 26 | 27 | - (BOOL)becomeFirstResponder { 28 | 29 | [self.textInputView becomeFirstResponder]; 30 | return YES; 31 | } 32 | 33 | - (void)setTextInputItem:(TextInputItem *)textInputItem { 34 | 35 | _textInputItem = textInputItem; 36 | 37 | self.titleLabel.text = textInputItem.title; 38 | 39 | [self.textInputView removeFromSuperview]; 40 | if (textInputItem.textInputType == TextInputTextField) { 41 | 42 | UITextField *textField = [self textField]; 43 | textField.placeholder = textInputItem.placeholder; 44 | textField.text = textInputItem.text; 45 | textField.keyboardType = textInputItem.keyboardType; 46 | self.textInputView = textField; 47 | [self.contentView addSubview:self.textInputView]; 48 | 49 | }else { 50 | UITextView *textView = [self textView]; 51 | textView.keyboardType = textInputItem.keyboardType; 52 | textView.text = textInputItem.text; 53 | self.textInputView = textView; 54 | [self.contentView addSubview:self.textInputView]; 55 | } 56 | 57 | [self.titleLabel sizeToFit]; 58 | self.titleLabel.left = kContentLeftAndRightMargin; 59 | self.textInputView.left = self.titleLabel.right; 60 | } 61 | 62 | #pragma mark - delegate 63 | 64 | - (void)textViewDidBeginEditing:(UITextView *)textView { 65 | 66 | if (self.textInputChange) { 67 | self.textInputChange(); 68 | } 69 | } 70 | 71 | - (void)textViewDidChange:(UITextView *)textView { 72 | 73 | self.textInputItem.text = textView.text; 74 | if ([self.delegate respondsToSelector:@selector(textInputCellTextChange:)]) { 75 | [self.delegate textInputCellTextChange:textView.text]; 76 | } 77 | } 78 | 79 | - (void)textFieldEdit:(UITextField *)textField { 80 | 81 | self.textInputItem.text = textField.text; 82 | 83 | if (self.textInputChange) { 84 | self.textInputChange(); 85 | return; 86 | } 87 | 88 | if ([self.delegate respondsToSelector:@selector(textInputCellTextChange:)]) { 89 | [self.delegate textInputCellTextChange:textField.text]; 90 | } 91 | } 92 | 93 | - (void)layoutSubviews { 94 | 95 | [super layoutSubviews]; 96 | self.titleLabel.centerY = self.height * 0.5; 97 | self.textInputView.width = self.width - 2 * kContentLeftAndRightMargin - self.titleLabel.width; 98 | if (self.textInputItem.textInputType == TextInputTextField) { 99 | self.textInputView.height = self.height; 100 | self.textInputView.top = 0; 101 | }else { 102 | self.textInputView.height = self.height - 10; 103 | self.textInputView.top = 5; 104 | } 105 | } 106 | 107 | - (UILabel *)titleLabel { 108 | 109 | if (!_titleLabel) { 110 | _titleLabel = [[UILabel alloc] init]; 111 | _titleLabel.font = [UIFont systemFontOfSize:15]; 112 | _titleLabel.textColor = [UIColor darkTextColor]; 113 | } 114 | return _titleLabel; 115 | } 116 | 117 | - (UITextField *)textField { 118 | 119 | UITextField *textField = [[UITextField alloc] init]; 120 | 121 | [textField addTarget:self action:@selector(textFieldEdit:) forControlEvents:UIControlEventAllEditingEvents]; 122 | textField.clearButtonMode = UITextFieldViewModeWhileEditing; 123 | textField.font = [UIFont systemFontOfSize:15]; 124 | textField.textColor = [UIColor darkTextColor]; 125 | return textField; 126 | } 127 | 128 | - (UITextView *)textView { 129 | 130 | UITextView *textView = [[UITextView alloc] init]; 131 | textView.delegate = self; 132 | [textView setTextContainerInset:UIEdgeInsetsMake(5, 3, 5, 3)]; 133 | textView.clearsOnInsertion = YES; 134 | textView.layer.borderColor = [UIColor lightGrayColor].CGColor; 135 | textView.layer.borderWidth = 1 / [UIScreen mainScreen].scale; 136 | textView.font = [UIFont systemFontOfSize:15]; 137 | textView.textColor = [UIColor darkTextColor]; 138 | return textView; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputCell/TextInputItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextInputItem.h 3 | // Copyright © 2017年 YeLiang. All rights reserved. 4 | // 5 | 6 | 7 | #import 8 | 9 | typedef enum : NSUInteger { 10 | TextInputTextField, 11 | TextInputTextView, 12 | } TextInputType; 13 | 14 | @interface TextInputItem : NSObject 15 | @property (nonatomic,copy) NSString *title; 16 | @property (nonatomic,copy) NSString *text; 17 | @property (nonatomic,copy) NSString *placeholder; 18 | @property (nonatomic,assign) UIKeyboardType keyboardType; 19 | @property (nonatomic,assign) TextInputType textInputType; 20 | 21 | + (instancetype)textInputItemWithPlaceholder:(NSString *)placeholder text:(NSString *)text; 22 | + (instancetype)textInputItemWithWithTitle:(NSString *)title Placeholder:(NSString *)placeholder text:(NSString *)text; 23 | + (instancetype)textInputItemWithPlaceholder:(NSString *)placeholder text:(NSString *)text textInputType:(TextInputType)textInputType; 24 | 25 | + (instancetype)textInputItemWithTitle:(NSString *)title Placeholder:(NSString *)placeholder textInputType:(TextInputType)textInputType; 26 | 27 | + (instancetype)textInputItemWithTitle:(NSString *)title Placeholder:(NSString *)placeholder text:(NSString *)text textInputType:(TextInputType)textInputType; 28 | @end 29 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputCell/TextInputItem.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // TextInputItem.m 4 | // Copyright © 2017年 YeLiang. All rights reserved. 5 | // 6 | 7 | #import "TextInputItem.h" 8 | 9 | @implementation TextInputItem 10 | + (instancetype)textInputItemWithPlaceholder:(NSString *)placeholder text:(NSString *)text { 11 | 12 | return [self textInputItemWithPlaceholder:placeholder text:text textInputType:TextInputTextField]; 13 | } 14 | 15 | + (instancetype)textInputItemWithWithTitle:(NSString *)title Placeholder:(NSString *)placeholder text:(NSString *)text { 16 | return [self textInputItemWithTitle:title Placeholder:placeholder text:text textInputType:TextInputTextField]; 17 | } 18 | 19 | + (instancetype)textInputItemWithPlaceholder:(NSString *)placeholder text:(NSString *)text textInputType:(TextInputType)textInputType { 20 | 21 | return [self textInputItemWithTitle:nil Placeholder:placeholder text:text textInputType:TextInputTextField]; 22 | } 23 | 24 | 25 | + (instancetype)textInputItemWithTitle:(NSString *)title Placeholder:(NSString *)placeholder textInputType:(TextInputType)textInputType { 26 | 27 | return [self textInputItemWithTitle:title Placeholder:placeholder text:nil textInputType:textInputType]; 28 | } 29 | 30 | + (instancetype)textInputItemWithTitle:(NSString *)title Placeholder:(NSString *)placeholder text:(NSString *)text textInputType:(TextInputType)textInputType { 31 | 32 | TextInputItem *item = [[TextInputItem alloc] init]; 33 | item.title = title; 34 | item.placeholder = placeholder; 35 | item.text = text; 36 | item.textInputType = textInputType; 37 | return item; 38 | } 39 | @end 40 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineTextInputVC.h 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/9. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SingleLineTextInputVC : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/SingleLineTextInputVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineTextInputVC.m 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/9. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import "SingleLineTextInputVC.h" 10 | #import "TextInputCell.h" 11 | #import "TextInputItem.h" 12 | 13 | @interface SingleLineTextInputVC () 14 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 15 | @property (nonatomic,strong) NSMutableArray *dataArray; 16 | @end 17 | 18 | @implementation SingleLineTextInputVC 19 | 20 | - (void)viewDidLoad { 21 | 22 | [super viewDidLoad]; 23 | self.automaticallyAdjustsScrollViewInsets = NO; 24 | [self.tableView registerClass:[TextInputCell class] forCellReuseIdentifier:@"TextInputCell"]; 25 | self.tableView.tableFooterView = [[UIView alloc] init]; 26 | } 27 | 28 | - (void)viewDidAppear:(BOOL)animated { 29 | 30 | [super viewDidAppear:animated]; 31 | NSArray *array = [self.tableView visibleCells]; 32 | UITableViewCell *cell = array.firstObject; 33 | [cell becomeFirstResponder]; 34 | } 35 | 36 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 37 | 38 | return self.dataArray.count; 39 | } 40 | 41 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 42 | 43 | TextInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TextInputCell"]; 44 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 45 | TextInputItem *item = self.dataArray[indexPath.row]; 46 | cell.textInputItem = item; 47 | return cell; 48 | } 49 | 50 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 51 | 52 | if (indexPath.row == 2) { 53 | return 100; 54 | } 55 | return 60; 56 | } 57 | 58 | - (NSMutableArray *)dataArray { 59 | 60 | if (!_dataArray) { 61 | 62 | _dataArray = [NSMutableArray array]; 63 | 64 | TextInputItem *receiverItem = [TextInputItem textInputItemWithPlaceholder:@"请输入收货人姓名" text:nil]; 65 | TextInputItem *phoneItem = [TextInputItem textInputItemWithWithTitle:@"手机号: " Placeholder:@"请输入11位手机号" text:@"13000000000"]; 66 | phoneItem.keyboardType = UIKeyboardTypeNumberPad; 67 | TextInputItem *detailAddressItem = [TextInputItem textInputItemWithTitle:@"详细地址: " Placeholder:@"请输入详细地址" textInputType:TextInputTextView]; 68 | [_dataArray addObjectsFromArray:@[receiverItem,phoneItem,detailAddressItem]]; 69 | } 70 | return _dataArray; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/UIView+Frame.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Frame.h 3 | // Sinfo 4 | // 5 | // Created by xiaoyu on 16/6/29. 6 | // Copyright © 2016年 YaoZhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum : NSUInteger { 12 | SKOscillatoryAnimationToBigger, 13 | SKOscillatoryAnimationToSmaller, 14 | } SKOscillatoryAnimationType; 15 | 16 | @interface UIView (Frame) 17 | @property (nonatomic) CGFloat left; 18 | @property (nonatomic) CGFloat top; 19 | @property (nonatomic) CGFloat right; 20 | @property (nonatomic) CGFloat bottom; 21 | @property (nonatomic) CGFloat width; 22 | @property (nonatomic) CGFloat height; 23 | @property (nonatomic) CGFloat centerX; ///< Shortcut for center.x 24 | @property (nonatomic) CGFloat centerY; ///< Shortcut for center.y 25 | @property (nonatomic) CGPoint origin; 26 | @property (nonatomic) CGSize size; 27 | @property (nonatomic, readonly) CGFloat screenX; 28 | @property (nonatomic, readonly) CGFloat screenY; 29 | 30 | + (void)showOscillatoryAnimationWithLayer:(CALayer *)layer 31 | type:(SKOscillatoryAnimationType)type; 32 | @end 33 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/UIView+Frame.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Frame.m 3 | // Sinfo 4 | // 5 | // Created by xiaoyu on 16/6/29. 6 | // Copyright © 2016年 YaoZhong. All rights reserved. 7 | // 8 | 9 | #import "UIView+Frame.h" 10 | 11 | @implementation UIView (Frame) 12 | - (CGFloat)left 13 | { 14 | return self.frame.origin.x; 15 | } 16 | 17 | - (void)setLeft:(CGFloat)x 18 | { 19 | CGRect frame = self.frame; 20 | frame.origin.x = x; 21 | self.frame = frame; 22 | } 23 | 24 | - (CGFloat)top 25 | { 26 | return self.frame.origin.y; 27 | } 28 | 29 | - (void)setTop:(CGFloat)y 30 | { 31 | CGRect frame = self.frame; 32 | frame.origin.y = y; 33 | self.frame = frame; 34 | } 35 | 36 | - (CGFloat)right 37 | { 38 | return self.frame.origin.x + self.frame.size.width; 39 | } 40 | 41 | - (void)setRight:(CGFloat)right 42 | { 43 | CGRect frame = self.frame; 44 | frame.origin.x = right - frame.size.width; 45 | self.frame = frame; 46 | } 47 | 48 | - (CGFloat)bottom 49 | { 50 | return self.frame.origin.y + self.frame.size.height; 51 | } 52 | 53 | - (void)setBottom:(CGFloat)bottom 54 | { 55 | CGRect frame = self.frame; 56 | frame.origin.y = bottom - frame.size.height; 57 | self.frame = frame; 58 | } 59 | 60 | - (CGFloat)width 61 | { 62 | return self.frame.size.width; 63 | } 64 | 65 | - (void)setWidth:(CGFloat)width 66 | { 67 | CGRect frame = self.frame; 68 | frame.size.width = width; 69 | self.frame = frame; 70 | } 71 | 72 | - (CGFloat)height 73 | { 74 | return self.frame.size.height; 75 | } 76 | 77 | - (void)setHeight:(CGFloat)height 78 | { 79 | CGRect frame = self.frame; 80 | frame.size.height = height; 81 | self.frame = frame; 82 | } 83 | 84 | - (CGFloat)screenX 85 | { 86 | CGFloat x = 0; 87 | for (UIView* view = self; view; view = view.superview) { 88 | x += view.left; 89 | } 90 | return x; 91 | } 92 | 93 | - (CGFloat)screenY 94 | { 95 | CGFloat y = 0; 96 | for (UIView* view = self; view; view = view.superview) { 97 | y += view.top; 98 | } 99 | return y; 100 | } 101 | 102 | - (CGPoint)origin 103 | { 104 | return self.frame.origin; 105 | } 106 | 107 | - (void)setOrigin:(CGPoint)origin 108 | { 109 | CGRect frame = self.frame; 110 | frame.origin = origin; 111 | self.frame = frame; 112 | } 113 | 114 | - (CGFloat)centerX 115 | { 116 | return self.center.x; 117 | } 118 | 119 | - (void)setCenterX:(CGFloat)centerX 120 | { 121 | self.center = CGPointMake(centerX, self.center.y); 122 | } 123 | 124 | - (CGFloat)centerY 125 | { 126 | return self.center.y; 127 | } 128 | 129 | - (void)setCenterY:(CGFloat)centerY 130 | { 131 | self.center = CGPointMake(self.center.x, centerY); 132 | } 133 | 134 | - (CGSize)size 135 | { 136 | return self.frame.size; 137 | } 138 | 139 | - (void)setSize:(CGSize)size 140 | { 141 | CGRect frame = self.frame; 142 | frame.size = size; 143 | self.frame = frame; 144 | } 145 | 146 | + (void)showOscillatoryAnimationWithLayer:(CALayer *)layer type:(SKOscillatoryAnimationType)type{ 147 | NSNumber *animationScale1 = type == SKOscillatoryAnimationToBigger ? @(1.15) : @(0.5); 148 | NSNumber *animationScale2 = type == SKOscillatoryAnimationToBigger ? @(0.92) : @(1.15); 149 | 150 | [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{ 151 | [layer setValue:animationScale1 forKeyPath:@"transform.scale"]; 152 | } completion:^(BOOL finished) { 153 | [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{ 154 | [layer setValue:animationScale2 forKeyPath:@"transform.scale"]; 155 | } completion:^(BOOL finished) { 156 | [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{ 157 | [layer setValue:@(1.0) forKeyPath:@"transform.scale"]; 158 | } completion:nil]; 159 | }]; 160 | }]; 161 | } 162 | 163 | @end 164 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SingleLineLayoutCell.h" 11 | #import "SingleLineLayoutItem.h" 12 | #import "UIView+Frame.h" 13 | 14 | @interface ViewController () 15 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 16 | @property (nonatomic,strong) NSMutableArray *dataArray; 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | 23 | [super viewDidLoad]; 24 | self.automaticallyAdjustsScrollViewInsets = NO; 25 | [self.tableView registerClass:[SingleLineLayoutCell class] forCellReuseIdentifier:@"SingleLineLayoutCell"]; 26 | self.tableView.tableFooterView = [[UIView alloc] init]; 27 | } 28 | 29 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 30 | 31 | return self.dataArray.count; 32 | } 33 | 34 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 35 | 36 | SingleLineLayoutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SingleLineLayoutCell"]; 37 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 38 | SingleLineLayoutItem *item = self.dataArray[indexPath.row]; 39 | cell.recordSingleLineItem = item; 40 | return cell; 41 | } 42 | 43 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 44 | 45 | return 60; 46 | } 47 | 48 | - (NSMutableArray *)dataArray { 49 | 50 | if (!_dataArray) { 51 | 52 | _dataArray = [NSMutableArray array]; 53 | 54 | { 55 | SingleLineLayoutItem *item0 = [SingleLineLayoutItem itemWithTitle:@"弹窗" subtitle:@"subtitle" icon:@"3" rightType:SingleLineItemRightTypeArrow]; 56 | item0.iconWidth = 30; 57 | item0.operation = ^{ 58 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"It is so cool" message:@"Hello World !!! " delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; 59 | [alertView show]; 60 | }; 61 | [_dataArray addObject:item0]; 62 | } 63 | 64 | { 65 | SingleLineLayoutItem *item1 = [SingleLineLayoutItem itemWithTitle:@"push到下一控制器" rightType:SingleLineItemRightTypeArrow]; 66 | __weak typeof(self) weakSelf = self; 67 | item1.operation = ^{ 68 | UIViewController *vc = [[UIViewController alloc] init]; 69 | vc.view.backgroundColor = [UIColor cyanColor]; 70 | [weakSelf.navigationController pushViewController:vc animated:YES]; 71 | }; 72 | [_dataArray addObject:item1]; 73 | } 74 | 75 | { 76 | SingleLineLayoutItem *item2 = [SingleLineLayoutItem itemWithTitle:@"标题2" subtitle:@"the subtitle length is so long . oh my god" icon:@"4" rightType:SingleLineItemRightTypeCustomView]; 77 | item2.iconWidth = 30; 78 | UIImageView *icon = [[UIImageView alloc] init]; 79 | icon.image = [UIImage imageNamed:@"4"]; 80 | icon.size = CGSizeMake(30, 30); 81 | item2.rightView = icon; 82 | [_dataArray addObject:item2]; 83 | } 84 | 85 | { 86 | SingleLineLayoutItem *item3 = [SingleLineLayoutItem itemWithTitle:@"这个标题有点长。真的有点长" rightType:SingleLineItemRightTypeCheck]; 87 | [_dataArray addObject:item3]; 88 | } 89 | 90 | { 91 | SingleLineLayoutItem *item4 = [SingleLineLayoutItem itemWithTitle:@"我的收藏(99)" subtitle:@"详细信息" icon:@"" rightType:SingleLineItemRightTypeArrowAndCustomView]; 92 | UILabel *rightLabel = [[UILabel alloc] init]; 93 | rightLabel.font = [UIFont systemFontOfSize:13]; 94 | rightLabel.text = @"右侧自定义的视图"; 95 | rightLabel.textColor = [UIColor orangeColor]; 96 | [rightLabel sizeToFit]; 97 | item4.rightView = rightLabel; 98 | [_dataArray addObject:item4]; 99 | } 100 | 101 | { 102 | SingleLineLayoutItem *item5 = [SingleLineLayoutItem itemWithTitle:@"我的消息(5)" subtitle:@"详细信息" rightType:SingleLineItemRightTypeCustomView]; 103 | item5.titleAttributes = @{NSForegroundColorAttributeName : [UIColor redColor]}; 104 | item5.subTitleAttributes = @{NSForegroundColorAttributeName : [UIColor cyanColor]}; 105 | item5.rightView = [[UISwitch alloc] init]; 106 | [_dataArray addObject:item5]; 107 | } 108 | } 109 | return _dataArray; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /SingleLineLayoutCell/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SingleLineLayoutCell 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. 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 | -------------------------------------------------------------------------------- /SingleLineLayoutCellTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SingleLineLayoutCellTests/SingleLineLayoutCellTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineLayoutCellTests.m 3 | // SingleLineLayoutCellTests 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SingleLineLayoutCellTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SingleLineLayoutCellTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /SingleLineLayoutCellUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SingleLineLayoutCellUITests/SingleLineLayoutCellUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SingleLineLayoutCellUITests.m 3 | // SingleLineLayoutCellUITests 4 | // 5 | // Created by Sekorm on 2017/5/4. 6 | // Copyright © 2017年 YL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SingleLineLayoutCellUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SingleLineLayoutCellUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------