├── .swift-version ├── HSSetTableViewCtrollerDemo ├── HSSetTableViewCtrollerDemo │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── MoreMyAlbum.imageset │ │ │ ├── MoreMyAlbum@2x.png │ │ │ ├── MoreMyAlbum@3x.png │ │ │ └── Contents.json │ │ ├── MoreSetting.imageset │ │ │ ├── MoreSetting@2x.png │ │ │ ├── MoreSetting@3x.png │ │ │ └── Contents.json │ │ ├── ic_icon_red.imageset │ │ │ ├── ic_icon_red@2x.png │ │ │ ├── ic_icon_red@3x.png │ │ │ └── Contents.json │ │ ├── ProfileLockOn.imageset │ │ │ ├── ProfileLockOn@2x.png │ │ │ ├── ProfileLockOn@3x.png │ │ │ └── Contents.json │ │ ├── ic_icon_photo.imageset │ │ │ ├── ic_icon_photo@2x.png │ │ │ ├── ic_icon_photo@3x.png │ │ │ └── Contents.json │ │ ├── ic_icon_super.imageset │ │ │ ├── ic_icon_super@2x.png │ │ │ ├── ic_icon_super@3x.png │ │ │ └── Contents.json │ │ ├── MoreMyBankCard.imageset │ │ │ ├── MoreMyBankCard@2x.png │ │ │ ├── MoreMyBankCard@3x.png │ │ │ └── Contents.json │ │ ├── ic_icon_header.imageset │ │ │ ├── ic_icon_header@2x.png │ │ │ ├── ic_icon_header@3x.png │ │ │ └── Contents.json │ │ ├── ic_icon_qrCode.imageset │ │ │ ├── ic_icon_qrCode@2x.png │ │ │ ├── ic_icon_qrCode@3x.png │ │ │ └── Contents.json │ │ ├── MoreMyFavorites.imageset │ │ │ ├── MoreMyFavorites@2x.png │ │ │ ├── MoreMyFavorites@3x.png │ │ │ └── Contents.json │ │ ├── MoreExpressionShops.imageset │ │ │ ├── MoreExpressionShops@2x.png │ │ │ ├── MoreExpressionShops@3x.png │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── ViewController.h │ ├── Ctrollers │ │ ├── custom │ │ │ ├── HSHeaderCellModel.m │ │ │ ├── HSZhiHuCustomCellModel.m │ │ │ ├── HSHeaderTableViewCell.h │ │ │ ├── HSZhiHuCustomTableViewCell.h │ │ │ ├── HSHeaderCellModel.h │ │ │ ├── HSZhiHuCustomCellModel.h │ │ │ ├── HSHeaderTableViewCell.m │ │ │ └── HSZhiHuCustomTableViewCell.m │ │ ├── HSCategoryViewController.h │ │ ├── HSZhiHuTableViewController.h │ │ ├── HSSetTableInfoController.h │ │ ├── HSSetTableViewQQController.h │ │ ├── HSSetTableViewCustomController.h │ │ ├── HSSetTableViewMeController.h │ │ ├── HSSetTableViewOtherController.h │ │ ├── HSSetTableViewCustomController.m │ │ ├── HSZhiHuTableViewController.m │ │ ├── HSCategoryViewController.m │ │ ├── HSSetTableViewMeController.m │ │ ├── HSSetTableViewOtherController.m │ │ ├── HSSetTableViewQQController.m │ │ └── HSSetTableInfoController.m │ ├── Tool │ │ └── SDWebImage │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── SDWebImageOperation.h │ │ │ ├── UIImage+GIF.h │ │ │ ├── SDWebImageDecoder.h │ │ │ ├── UIImage+WebP.h │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── UIView+WebCacheOperation.h │ │ │ ├── NSData+ImageContentType.m │ │ │ ├── SDWebImageCompat.m │ │ │ ├── SDWebImageCompat.h │ │ │ ├── UIView+WebCacheOperation.m │ │ │ ├── UIImage+WebP.m │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ ├── UIImage+MultiFormat.m │ │ │ ├── SDWebImageDecoder.m │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── MKAnnotationView+WebCache.m │ │ │ ├── SDWebImagePrefetcher.m │ │ │ ├── UIImageView+HighlightedWebCache.h │ │ │ ├── UIImageView+HighlightedWebCache.m │ │ │ ├── UIImage+GIF.m │ │ │ └── MKAnnotationView+WebCache.h │ ├── AppDelegate.h │ ├── main.m │ ├── Info.plist │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── AppDelegate.m │ └── ViewController.m ├── HSSetTableViewCtrollerDemo.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── hushaohui.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── hushaohui.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── HSSetTableViewCtrollerDemo.xcscheme ├── HSSetTableViewCtrollerDemoTests │ ├── Info.plist │ └── HSSetTableViewCtrollerDemoTests.m └── HSSetTableViewCtrollerDemoUITests │ ├── Info.plist │ └── HSSetTableViewCtrollerDemoUITests.m ├── HSSetTableViewController ├── HSSetTableViewController.bundle │ ├── ic_hs_tableView_arrow@2x.png │ └── ic_hs_tableView_arrow@3x.png ├── Model │ ├── HSFooterModel.m │ ├── HSHeaderModel.m │ ├── HSTitleTableViewCell.h │ ├── HSFooterModel.h │ ├── HSHeaderModel.h │ ├── HSCustomCellModel.h │ ├── HSSwitchCellModel.m │ ├── HSSwitchCellModel.h │ ├── HSImageCellModel.m │ ├── HSBaseCellModel.m │ ├── HSCustomCellModel.m │ ├── HSBaseCellModel.h │ ├── HSImageCellModel.h │ ├── HSTitleCellModel.h │ ├── HSTextCellModel.h │ ├── HSTitleCellModel.m │ └── HSTitleTableViewCell.m ├── View │ ├── HSCustomTableViewCell.h │ ├── HSSwitchTableViewCell.h │ ├── HSImageTableViewCell.h │ ├── HSTextTableViewCell.h │ ├── HSBaseTableViewCell.h │ ├── HSCustomTableViewCell.m │ ├── HSBaseTableViewCell.m │ ├── HSSwitchTableViewCell.m │ ├── HSTextTableViewCell.m │ └── HSImageTableViewCell.m ├── Category │ ├── NSArray+HSSafeAccess.h │ ├── UIColor+HSExtension.h │ ├── NSArray+HSSafeAccess.m │ ├── NSString+HSHeight.h │ ├── NSBundle+HSImage.h │ ├── UIView+HSFrame.h │ ├── NSBundle+HSImage.m │ ├── UIColor+HSExtension.m │ ├── NSString+HSHeight.m │ └── UIView+HSFrame.m ├── manager │ ├── HSSetTableViewManager.h │ ├── UIViewController+HSSetTableView.h │ └── HSSetTableViewManager.m ├── HSSetTableViewControllerConst.m ├── HSSetTableViewController.h ├── Ctroller │ └── HSSetTableViewMainController.h └── HSSetTableViewControllerConst.h ├── .gitignore ├── LICENSE └── HSSetTableViewController.podspec /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /HSSetTableViewController/HSSetTableViewController.bundle/ic_hs_tableView_arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewController/HSSetTableViewController.bundle/ic_hs_tableView_arrow@2x.png -------------------------------------------------------------------------------- /HSSetTableViewController/HSSetTableViewController.bundle/ic_hs_tableView_arrow@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewController/HSSetTableViewController.bundle/ic_hs_tableView_arrow@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyAlbum.imageset/MoreMyAlbum@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyAlbum.imageset/MoreMyAlbum@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyAlbum.imageset/MoreMyAlbum@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyAlbum.imageset/MoreMyAlbum@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreSetting.imageset/MoreSetting@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreSetting.imageset/MoreSetting@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreSetting.imageset/MoreSetting@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreSetting.imageset/MoreSetting@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_red.imageset/ic_icon_red@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_red.imageset/ic_icon_red@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_red.imageset/ic_icon_red@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_red.imageset/ic_icon_red@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ProfileLockOn.imageset/ProfileLockOn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ProfileLockOn.imageset/ProfileLockOn@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ProfileLockOn.imageset/ProfileLockOn@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ProfileLockOn.imageset/ProfileLockOn@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_photo.imageset/ic_icon_photo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_photo.imageset/ic_icon_photo@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_photo.imageset/ic_icon_photo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_photo.imageset/ic_icon_photo@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_super.imageset/ic_icon_super@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_super.imageset/ic_icon_super@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_super.imageset/ic_icon_super@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_super.imageset/ic_icon_super@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyBankCard.imageset/MoreMyBankCard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyBankCard.imageset/MoreMyBankCard@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyBankCard.imageset/MoreMyBankCard@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyBankCard.imageset/MoreMyBankCard@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_header.imageset/ic_icon_header@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_header.imageset/ic_icon_header@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_header.imageset/ic_icon_header@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_header.imageset/ic_icon_header@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_qrCode.imageset/ic_icon_qrCode@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_qrCode.imageset/ic_icon_qrCode@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_qrCode.imageset/ic_icon_qrCode@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_qrCode.imageset/ic_icon_qrCode@3x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyFavorites.imageset/MoreMyFavorites@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyFavorites.imageset/MoreMyFavorites@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyFavorites.imageset/MoreMyFavorites@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyFavorites.imageset/MoreMyFavorites@3x.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #.DS_Store 2 | 3 | # Xcode 4 | build/* 5 | *.pbxuser 6 | !default.pbxuser 7 | *.mode1v3 8 | !default.mode1v3 9 | *.mode2v3 10 | !default.mode2v3 11 | *.perspectivev3 12 | !default.perspectivev3 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | *.xcuserstate 18 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreExpressionShops.imageset/MoreExpressionShops@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreExpressionShops.imageset/MoreExpressionShops@2x.png -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreExpressionShops.imageset/MoreExpressionShops@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreExpressionShops.imageset/MoreExpressionShops@3x.png -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSFooterModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSFooterModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/10/25. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSFooterModel.h" 10 | 11 | @implementation HSFooterModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSHeaderModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/10/25. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSHeaderModel.h" 10 | 11 | @implementation HSHeaderModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo.xcodeproj/project.xcworkspace/xcuserdata/hushaohui.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaohuihu/HSSetTableViewController/HEAD/HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo.xcodeproj/project.xcworkspace/xcuserdata/hushaohui.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSCustomTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSCustomTableViewCell.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | 11 | @interface HSCustomTableViewCell : HSBaseTableViewCell 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSHeaderCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderCellModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSHeaderCellModel.h" 10 | 11 | @implementation HSHeaderCellModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSSwitchTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowSwitchRightCell.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | #import "HSTitleTableViewCell.h" 11 | @interface HSSwitchTableViewCell : HSTitleTableViewCell 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSZhiHuCustomCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuCellModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSZhiHuCustomCellModel.h" 10 | 11 | @implementation HSZhiHuCustomCellModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSCategoryViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSCategoryViewController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/7/24. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HSCategoryViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSImageTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowBigImageCell.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/21. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | #import "HSTitleTableViewCell.h" 11 | 12 | //右边大图cell 13 | @interface HSImageTableViewCell : HSTitleTableViewCell 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSTextTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowTextRightCell.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | #import "HSTitleTableViewCell.h" 11 | //右边有文本(箭头可显示也可隐藏) 12 | @interface HSTextTableViewCell : HSTitleTableViewCell 13 | 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSHeaderTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderTableViewCell.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomTableViewCell.h" 10 | 11 | @interface HSHeaderTableViewCell : HSCustomTableViewCell 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSTitleTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSTitleTableViewCell.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | 11 | @interface HSTitleTableViewCell : HSBaseTableViewCell 12 | @property (nonatomic, weak)UIImageView *arrow; ///< 箭头 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSZhiHuCustomTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuTableViewCell.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomTableViewCell.h" 10 | 11 | @interface HSZhiHuCustomTableViewCell : HSCustomTableViewCell 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSZhiHuTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuTableViewController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewMainController.h" 10 | 11 | @interface HSZhiHuTableViewController : HSSetTableViewMainController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSHeaderCellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderCellModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomCellModel.h" 10 | 11 | 12 | /** 13 | 微信头像cell 模型 14 | */ 15 | @interface HSHeaderCellModel : HSCustomCellModel 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. 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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableInfoController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableInfoController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewController.h" 10 | /** 11 | 微信个人信息 12 | */ 13 | @interface HSSetTableInfoController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewQQController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewQQController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/5/8. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewMainController.h" 10 | 11 | 12 | /** 13 | QQ个人资料 14 | */ 15 | @interface HSSetTableViewQQController : HSSetTableViewMainController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewCustomController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewCustomController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/5/23. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewMainController.h" 10 | 11 | 12 | /** 13 | 统一自定义风格 14 | */ 15 | @interface HSSetTableViewCustomController : HSSetTableViewMainController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. 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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewMeController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewMeController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewController.h" 10 | #import "HSSetTableViewController.h" 11 | 12 | /** 13 | 微信我 14 | */ 15 | @interface HSSetTableViewMeController : HSSetTableViewMainController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewOtherController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewOtherController.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewController.h" 10 | #import "UIViewController+HSSetTableView.h" 11 | 12 | /** 13 | 复杂界面 14 | */ 15 | @interface HSSetTableViewOtherController : UIViewController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/NSArray+HSSafeAccess.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+HSSafeAccess.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (HSSafeAccess) 12 | 13 | 14 | /** 15 | 按照索引安全返回数组元素 16 | 17 | @param index 索引index 18 | @return self 19 | */ 20 | - (instancetype)hs_objectWithIndex:(NSUInteger)index; 21 | 22 | @end 23 | 24 | 25 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/UIColor+HSExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HSExtension.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HSExtension) 12 | 13 | //color颜色分类方法 14 | + (instancetype)hs_colorWithHexString:(NSString *)hexString; 15 | //hs_color颜色分类方法 16 | + (instancetype)hs_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSFooterModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSFooterModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/10/25. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | 尾部视图模型 14 | */ 15 | @interface HSFooterModel : NSObject 16 | 17 | @property (nonatomic, strong)UIView *footerView; ///<尾部视图 18 | @property (nonatomic, assign)CGFloat footerViewHeight; ///<尾部视图高度 19 | @end 20 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSHeaderModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/10/25. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | 头部视图模型 14 | */ 15 | @interface HSHeaderModel : NSObject 16 | 17 | @property (nonatomic, strong)UIView *headerView; ///<头部视图 18 | @property (nonatomic, assign)CGFloat headerViewHeight; ///<头部视图高度 19 | @end 20 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/NSArray+HSSafeAccess.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+HSSafeAccess.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "NSArray+HSSafeAccess.h" 10 | 11 | @implementation NSArray (HSSafeAccess) 12 | 13 | - (instancetype)hs_objectWithIndex:(NSUInteger)index 14 | { 15 | if (index < self.count) { 16 | return self[index]; 17 | }else{ 18 | return nil; 19 | } 20 | } 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/NSString+HSHeight.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HSHeight.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface NSString (HSHeight) 12 | 13 | 14 | 15 | /** 16 | 计算文本高度方法 17 | 18 | @param font 字体大小 19 | @param width 宽度 20 | @return 文字高度 21 | */ 22 | - (CGFloat)hs_heightWithFont:(UIFont *)font constrainedToWidth:(CGFloat)width; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyAlbum.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "MoreMyAlbum@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "MoreMyAlbum@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreSetting.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "MoreSetting@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "MoreSetting@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_red.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_icon_red@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ic_icon_red@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ProfileLockOn.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ProfileLockOn@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ProfileLockOn@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_photo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_icon_photo@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ic_icon_photo@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_super.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_icon_super@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ic_icon_super@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyBankCard.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "MoreMyBankCard@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "MoreMyBankCard@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_header.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_icon_header@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ic_icon_header@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/ic_icon_qrCode.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_icon_qrCode@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "ic_icon_qrCode@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreMyFavorites.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "MoreMyFavorites@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "MoreMyFavorites@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Assets.xcassets/MoreExpressionShops.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "MoreExpressionShops@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "MoreExpressionShops@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HSSetTableViewController/Category/NSBundle+HSImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+HSImage.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/26. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface NSBundle (HSImage) 12 | 13 | 14 | /** 15 | 图片bundl 16 | 17 | @return bundle 18 | */ 19 | + (NSBundle *)hs_Bundle; 20 | 21 | 22 | /** 23 | 获取bundle图片 24 | 25 | @param name 图片name 26 | @return image 27 | */ 28 | + (UIImage *)hs_imageNamed:(NSString *)name; 29 | @end 30 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+WebP.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+WebP.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #ifdef SD_WEBP 10 | 11 | #import 12 | 13 | // Fix for issue #416 Undefined symbols for architecture armv7 since WebP introduction when deploying to device 14 | void WebPInitPremultiplyNEON(void); 15 | 16 | void WebPInitUpsamplersNEON(void); 17 | 18 | void VP8DspInitNEON(void); 19 | 20 | @interface UIImage (WebP) 21 | 22 | + (UIImage *)sd_imageWithWebPData:(NSData *)data; 23 | 24 | @end 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSZhiHuCustomCellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuCellModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomCellModel.h" 10 | 11 | @class HSZhiHuCustomCellModel; 12 | typedef void(^switchItemBlock)(HSZhiHuCustomCellModel *model,BOOL on); 13 | @interface HSZhiHuCustomCellModel : HSCustomCellModel 14 | 15 | @property (nonatomic, assign)BOOL hideSwitch; ///<是否隐藏开关 16 | @property (nonatomic, assign)BOOL on; ///< 17 | //还可以定义block按钮点击属性,以及开关初始化状态等等..由业务控制model作为中间层 18 | @property (nonatomic, copy) switchItemBlock block; ///< 19 | @end 20 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo.xcodeproj/xcuserdata/hushaohui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | 10 | /** 11 | * Compute the content type for an image data 12 | * 13 | * @param data the input data 14 | * 15 | * @return the content type as string (i.e. image/jpeg, image/gif) 16 | */ 17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data; 18 | 19 | @end 20 | 21 | 22 | @interface NSData (ImageContentTypeDeprecated) 23 | 24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSCustomCellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSCustomCellModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseCellModel.h" 10 | 11 | /** 12 | 自定义cell model基类 13 | */ 14 | @interface HSCustomCellModel : HSBaseCellModel 15 | 16 | @property (nonatomic, copy ) NSString *text;///<基类开放的属性(可用可不用,也可以自己定义熟悉) 17 | @property (nonatomic, copy ) NSString *detailText; ///<基类开放属性(可用可不用,也可以自己定义属性) 18 | 19 | /** 20 | 自定义模型初始化方法,请特别注意调用自定义模型方法后,cell必须自定义切存在 21 | 22 | @param cellIdentifier 自定义cell类名,作为唯一标示符 23 | @param block 回调block 24 | @return self 25 | */ 26 | - (instancetype)initWithCellIdentifier:(NSString *)cellIdentifier actionBlock:(ClickActionBlock)block; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /HSSetTableViewController/manager/HSSetTableViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewManager.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/7/24. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @class HSFooterModel,HSHeaderModel; 14 | @interface HSSetTableViewManager : NSObject 15 | 16 | 17 | @property (nonatomic, strong)NSArray *footerArry; ///footer 数组 18 | @property (nonatomic, strong)NSArray *headerArry; ///
14 | 15 | NSString *const HSBaseCellModelCellClass = @"HSBaseTableViewCell"; 16 | NSString *const HSTitleCellModelCellClass = @"HSTitleTableViewCell"; 17 | NSString *const HSImageCellModelCellClass = @"HSImageTableViewCell"; 18 | NSString *const HSSwitchCellModelCellClass = @"HSSwitchTableViewCell"; 19 | NSString *const HSTextCellModelCellClass = @"HSTextTableViewCell"; 20 | 21 | 22 | #endif /* HSSetTableViewControllConst_h */ 23 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSSwitchCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSwitchCellModel.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSwitchCellModel.h" 10 | #import "HSSetTableViewControllerConst.h" 11 | @implementation HSSwitchCellModel 12 | 13 | - (instancetype)initWithTitle:(NSString *)title switchType:(BOOL)on switchBlock:(switchBlock)block 14 | { 15 | if(self = [super initWithTitle:title actionBlock:nil]){ 16 | self.switchBlock = block; 17 | self.selectionStyle = UITableViewCellSelectionStyleNone; 18 | self.showArrow = NO; 19 | self.on = on; 20 | } 21 | return self; 22 | } 23 | 24 | - (NSString *)cellClass 25 | { 26 | return HSSwitchCellModelCellClass; 27 | } 28 | @end 29 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemoTests/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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemoUITests/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 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSBaseTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSBaseTableViewCell.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HSBaseCellModel; 11 | @interface HSBaseTableViewCell : UITableViewCell 12 | 13 | @property (nonatomic, strong)HSBaseCellModel *cellModel; /// 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HSSetTableViewCtrollerDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3BB3C49D1EAB991D004A9BA9 16 | 17 | primary 18 | 19 | 20 | 3BB3C4B61EAB991D004A9BA9 21 | 22 | primary 23 | 24 | 25 | 3BB3C4C11EAB991D004A9BA9 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/UIView+HSFrame.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HSFrame.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (HSFrame) 12 | 13 | @property (nonatomic, assign) CGFloat hs_x; 14 | @property (nonatomic, assign) CGFloat hs_y; 15 | @property (nonatomic, assign) CGFloat hs_centerX; 16 | @property (nonatomic, assign) CGFloat hs_centerY; 17 | @property (nonatomic, assign) CGFloat hs_width; 18 | @property (nonatomic, assign) CGFloat hs_height; 19 | @property (nonatomic, assign) CGSize hs_size; 20 | 21 | @end 22 | 23 | 24 | @interface CALayer (HSFrame) 25 | 26 | @property (nonatomic, assign) CGFloat hs_x; 27 | @property (nonatomic, assign) CGFloat hs_y; 28 | @property (nonatomic, assign) CGFloat hs_width; 29 | @property (nonatomic, assign) CGFloat hs_height; 30 | @property (nonatomic, assign) CGSize hs_size; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSCustomTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSCustomTableViewCell.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomTableViewCell.h" 10 | 11 | @implementation HSCustomTableViewCell 12 | 13 | +(HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView 14 | { 15 | HSCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 16 | if(cell == nil){ 17 | Class cellClass = NSClassFromString(cellIdentifier); 18 | NSAssert([cellClass isSubclassOfClass:[HSCustomTableViewCell class]], @"此cellclass类必须存在,并且继承HSCustomTableViewCell"); 19 | cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 20 | cell.accessoryType = UITableViewCellAccessoryNone; 21 | } 22 | return cell; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSImageCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSBigImageCellModel.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/21. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSImageCellModel.h" 10 | #import "HSSetTableViewControllerConst.h" 11 | 12 | @implementation HSImageCellModel 13 | - (instancetype)initWithTitle:(NSString *)title placeholderImage:(UIImage *)placeholderImage imageUrl:(NSString *)imageUrl actionBlock:(ClickActionBlock)actionblock imageBlock:(ClickImageBlock)imageBlock; 14 | { 15 | if(self = [super initWithTitle:title actionBlock:actionblock]){ 16 | self.placeHoderImage = placeholderImage; 17 | self.imageUrl = imageUrl; 18 | self.imageBlock = imageBlock; 19 | self.imageSize = CGSizeMake(HS_KImageWidth, HS_KImageHeight); 20 | self.cornerRadius = .0f; 21 | self.cellHeight = HS_KImageCellHeight; 22 | } 23 | return self; 24 | } 25 | 26 | - (NSString *)cellClass 27 | { 28 | return HSImageCellModelCellClass; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSBaseCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSBaseCellModel.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseCellModel.h" 10 | 11 | @interface HSBaseCellModel() 12 | { 13 | NSString *privateCellModelIdentifier;///<私有变量 14 | } 15 | 16 | @end 17 | 18 | @implementation HSBaseCellModel 19 | 20 | 21 | - (instancetype)init 22 | { 23 | if(self = [super init]){ 24 | //获取当前时间 25 | CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); 26 | //获取当前线程id 27 | NSString *threadNumber = [[[NSString stringWithFormat:@"%@",[NSThread currentThread]] componentsSeparatedByString:@"number = "].lastObject componentsSeparatedByString:@","].firstObject; 28 | privateCellModelIdentifier = [NSString stringWithFormat:@"%lf%@",now,threadNumber]; 29 | } 30 | 31 | return self; 32 | } 33 | 34 | - (NSString *)identifier 35 | { 36 | return privateCellModelIdentifier; 37 | } 38 | 39 | + (BOOL)accessInstanceVariablesDirectly 40 | { 41 | return NO; 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSCustomCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSCustomCellModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCustomCellModel.h" 10 | #import "HSSetTableViewControllerConst.h" 11 | 12 | @interface HSCustomCellModel() 13 | { 14 | NSString *privateCellClass;///<私有变量 15 | } 16 | 17 | @end 18 | @implementation HSCustomCellModel 19 | 20 | 21 | - (instancetype)initWithCellIdentifier:(NSString *)cellIdentifier actionBlock:(ClickActionBlock)block 22 | { 23 | if(self = [super init]){ 24 | self.cellHeight = HS_KCellHeight; 25 | self.actionBlock = block; 26 | self.selectionStyle = UITableViewCellSelectionStyleDefault; 27 | self.separateOffset = HS_KCellMargin; 28 | self.separateColor = HS_KSeparateColor; 29 | self.separateHeight = HS_KSeparateHeight; 30 | //cellClass 为与cell类名绑定的自定义cell类名必须一致,类名作为identifier的重用标示符号,如果不一致将报错。 31 | privateCellClass = cellIdentifier; 32 | } 33 | return self; 34 | } 35 | 36 | 37 | - (NSString *)cellClass 38 | { 39 | return privateCellClass; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @interface UIView (WebCacheOperation) 13 | 14 | /** 15 | * Set the image load operation (storage in a UIView based dictionary) 16 | * 17 | * @param operation the operation 18 | * @param key key for storing the operation 19 | */ 20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; 21 | 22 | /** 23 | * Cancel all operations for the current UIView and key 24 | * 25 | * @param key key for identifying the operations 26 | */ 27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; 28 | 29 | /** 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them 31 | * 32 | * @param key key for identifying the operations 33 | */ 34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemoTests/HSSetTableViewCtrollerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewCtrollerDemoTests.m 3 | // HSSetTableViewCtrollerDemoTests 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HSSetTableViewCtrollerDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation HSSetTableViewCtrollerDemoTests 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 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSBaseCellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSBaseCellModel.h 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HSBaseCellModel; 13 | typedef void(^ClickActionBlock)(HSBaseCellModel *model); 14 | @interface HSBaseCellModel : NSObject 15 | 16 | /** 17 | 基础属性 18 | */ 19 | @property (nonatomic, copy,readonly) NSString *identifier; ///<唯一标识符(更新会用到) 20 | @property (nonatomic, copy,readonly) NSString *cellClass; ///<该模型绑定的cell类名 21 | @property (nonatomic, strong) UIColor *backgroundColor; 22 | @property (nonatomic, assign) UITableViewCellSelectionStyle selectionStyle;//选中cell效果 23 | @property (nonatomic, assign) CGFloat cellHeight; /// "MIT", :file => "LICENSE" } 21 | s.author = { "hushaohui" => "hushaohui186@gmail.com" } 22 | 23 | s.source = { :git => "https://github.com/shaohuihu/HSSetTableViewController.git", :tag => s.version } 24 | s.source_files = "HSSetTableViewController/**/*.{h,m}" 25 | s.resources = "HSSetTableViewController/HSSetTableViewController.bundle" 26 | s.requires_arc = true 27 | s.framework = "UIKit" 28 | s.dependency 'SDWebImage' 29 | 30 | 31 | end 32 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import "NSData+ImageContentType.h" 7 | 8 | 9 | @implementation NSData (ImageContentType) 10 | 11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data { 12 | uint8_t c; 13 | [data getBytes:&c length:1]; 14 | switch (c) { 15 | case 0xFF: 16 | return @"image/jpeg"; 17 | case 0x89: 18 | return @"image/png"; 19 | case 0x47: 20 | return @"image/gif"; 21 | case 0x49: 22 | case 0x4D: 23 | return @"image/tiff"; 24 | case 0x52: 25 | // R as RIFF for WEBP 26 | if ([data length] < 12) { 27 | return nil; 28 | } 29 | 30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 32 | return @"image/webp"; 33 | } 34 | 35 | return nil; 36 | } 37 | return nil; 38 | } 39 | 40 | @end 41 | 42 | 43 | @implementation NSData (ImageContentTypeDeprecated) 44 | 45 | + (NSString *)contentTypeForImageData:(NSData *)data { 46 | return [self sd_contentTypeForImageData:data]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemoUITests/HSSetTableViewCtrollerDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewCtrollerDemoUITests.m 3 | // HSSetTableViewCtrollerDemoUITests 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HSSetTableViewCtrollerDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation HSSetTableViewCtrollerDemoUITests 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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSAppTransportSecurity 6 | 7 | NSAllowsArbitraryLoads 8 | 9 | 10 | CFBundleDevelopmentRegion 11 | en 12 | CFBundleExecutable 13 | $(EXECUTABLE_NAME) 14 | CFBundleIdentifier 15 | $(PRODUCT_BUNDLE_IDENTIFIER) 16 | CFBundleInfoDictionaryVersion 17 | 6.0 18 | CFBundleName 19 | $(PRODUCT_NAME) 20 | CFBundlePackageType 21 | APPL 22 | CFBundleShortVersionString 23 | 1.0 24 | CFBundleVersion 25 | 1 26 | LSRequiresIPhoneOS 27 | 28 | UILaunchStoryboardName 29 | LaunchScreen 30 | UIMainStoryboardFile 31 | Main 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | UIInterfaceOrientationPortrait 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /HSSetTableViewController/manager/UIViewController+HSSetTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HSSetTableView.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/7/24. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HSBaseCellModel,HSHeaderModel,HSFooterModel; 11 | @interface UIViewController (HSSetTableView) 12 | 13 | @property (nonatomic, strong)UITableView *hs_tableView; ///<表视图 14 | @property (nonatomic, strong)NSMutableArray *hs_dataArry; ///<数据源 15 | 16 | 17 | /** 18 | 设置当前tableView 约束 19 | 20 | @param top 上边距 默认0 21 | @param left 左边距 默认0 22 | @param right 右边距 默认0(正数是向右边) 23 | @param bottom 下边距 默认0(正数是向上边) 24 | */ 25 | - (void)setupTableViewConstrint:(CGFloat)top left:(CGFloat)left right:(CGFloat)right bottom:(CGFloat)bottom; 26 | /** 27 | 初始化tableView 类型 28 | 29 | @param style UITableViewStylePlain, // regular table view 30 | UITableViewStyleGrouped // preferences style table vie 31 | */ 32 | - (void)initSetTableViewConfigureStyle:(UITableViewStyle)style; 33 | 34 | /** 35 | 设置footerArry HSFooterModel 数组 36 | 37 | @param footerArry footerArry 38 | */ 39 | - (void)setTableViewFooterArry:(NSMutableArray *)footerArry; 40 | 41 | 42 | /** 43 | 设置headerArry HSHeaderModel数组 44 | 45 | @param headerArry headerArry 46 | */ 47 | - (void)setTableViewHeaderArry:(NSMutableArray *)headerArry; 48 | 49 | /** 50 | 更新cell模型方法 51 | 52 | @param cellModel model 53 | */ 54 | - (void)updateCellModel:(HSBaseCellModel *)cellModel; 55 | 56 | 57 | /** 58 | 更新cell模型方法 59 | 60 | @param cellModel model 61 | @param animation 动画效果 62 | */ 63 | - (void)updateCellModel:(HSBaseCellModel *)cellModel animation:(UITableViewRowAnimation)animation; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageCompat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 11/12/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if !__has_feature(objc_arc) 12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 13 | #endif 14 | 15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | if ([image.images count] > 0) { 21 | NSMutableArray *scaledImages = [NSMutableArray array]; 22 | 23 | for (UIImage *tempImage in image.images) { 24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 25 | } 26 | 27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 28 | } 29 | else { 30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 31 | CGFloat scale = [UIScreen mainScreen].scale; 32 | if (key.length >= 8) { 33 | NSRange range = [key rangeOfString:@"@2x."]; 34 | if (range.location != NSNotFound) { 35 | scale = 2.0; 36 | } 37 | 38 | range = [key rangeOfString:@"@3x."]; 39 | if (range.location != NSNotFound) { 40 | scale = 3.0; 41 | } 42 | } 43 | 44 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 45 | image = scaledImage; 46 | } 47 | return image; 48 | } 49 | } 50 | 51 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 52 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/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 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSTitleCellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HSTitleCellModel.h 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseCellModel.h" 10 | 11 | @interface HSTitleCellModel : HSBaseCellModel 12 | 13 | /** 14 | 显示相关 15 | */ 16 | @property (nonatomic, copy ) NSAttributedString *attributeTitle; /// 10 | 11 | @class HSBaseCellModel; 12 | 13 | /** 14 | 主控制器 15 | */ 16 | @interface HSSetTableViewMainController : UIViewController 17 | 18 | 19 | 20 | @property (nonatomic, weak)UITableView *hs_tableView; /// 15 | #import 16 | #import "UIColor+HSExtension.h" 17 | 18 | 19 | //标题左边的默认cell间距 20 | #define HS_KCellMargin 15.0 21 | //cell分割线默认高度 22 | #define HS_KSeparateHeight .5 23 | //cell分割线默认颜色 24 | #define HS_KSeparateColor [UIColor hs_colorWithHexString:@"#e6e6e6"] 25 | //标题默认字体大小 26 | #define HS_KTitleFont [UIFont systemFontOfSize:15.0] 27 | //标题默认字体颜色 28 | #define HS_KTitleColor [UIColor blackColor] 29 | //详细文本默认字体大小 30 | #define HS_KDetailFont [UIFont systemFontOfSize:13.0] 31 | //标题默详细文本字体颜色 32 | #define HS_KDetailColor [UIColor grayColor] 33 | //分组section之间的距离 34 | #define HS_SectionHeight 10 35 | 36 | //箭头默认宽度 37 | #define HS_KArrowWidth 8 38 | //箭头默认高度 39 | #define HS_kArrowHeight 13 40 | //右边文本离左边的边距 41 | #define HS_KCellTextLeftPading 150 42 | //距离cell上下默认边距pading 43 | #define HS_KCellPading 5 44 | //cell默认高度 45 | #define HS_KCellHeight 44 46 | //开关默认宽度 47 | #define HS_KSwitchWidth 50 48 | //开关默认高度 49 | #define HS_KSwitchHeight 30 50 | //大图默认cell高度 51 | #define HS_KImageCellHeight 90 52 | //右边大图默认宽度 53 | #define HS_KImageWidth 60 54 | //右边大图默认高度 55 | #define HS_KImageHeight 60 56 | //屏幕宏定义 57 | #define HS_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 58 | #define HS_SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 59 | //Log打印 60 | #ifdef DEBUG 61 | # define HSLog(fmt, ...) NSLog((@"行: %d > " fmt), __LINE__, ##__VA_ARGS__); 62 | #else 63 | # define HSLog(...); 64 | #endif 65 | 66 | UIKIT_EXTERN NSString *const HSTitleCellModelCellClass; 67 | UIKIT_EXTERN NSString *const HSBaseCellModelCellClass; 68 | UIKIT_EXTERN NSString *const HSImageCellModelCellClass; 69 | UIKIT_EXTERN NSString *const HSSwitchCellModelCellClass; 70 | UIKIT_EXTERN NSString *const HSTextCellModelCellClass; 71 | 72 | 73 | #endif /* HSSetTableViewConst_h */ 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployment Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | typedef void(^SDWebImageNoParamsBlock)(); 57 | 58 | extern NSString *const SDWebImageErrorDomain; 59 | 60 | #define dispatch_main_sync_safe(block)\ 61 | if ([NSThread isMainThread]) {\ 62 | block();\ 63 | } else {\ 64 | dispatch_sync(dispatch_get_main_queue(), block);\ 65 | } 66 | 67 | #define dispatch_main_async_safe(block)\ 68 | if ([NSThread isMainThread]) {\ 69 | block();\ 70 | } else {\ 71 | dispatch_async(dispatch_get_main_queue(), block);\ 72 | } 73 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIView+WebCacheOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIView+WebCacheOperation.h" 10 | #import "objc/runtime.h" 11 | 12 | static char loadOperationKey; 13 | 14 | @implementation UIView (WebCacheOperation) 15 | 16 | - (NSMutableDictionary *)operationDictionary { 17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 18 | if (operations) { 19 | return operations; 20 | } 21 | operations = [NSMutableDictionary dictionary]; 22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | return operations; 24 | } 25 | 26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { 27 | [self sd_cancelImageLoadOperationWithKey:key]; 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 29 | [operationDictionary setObject:operation forKey:key]; 30 | } 31 | 32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { 33 | // Cancel in progress downloader from queue 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 35 | id operations = [operationDictionary objectForKey:key]; 36 | if (operations) { 37 | if ([operations isKindOfClass:[NSArray class]]) { 38 | for (id operation in operations) { 39 | if (operation) { 40 | [operation cancel]; 41 | } 42 | } 43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 44 | [(id) operations cancel]; 45 | } 46 | [operationDictionary removeObjectForKey:key]; 47 | } 48 | } 49 | 50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key { 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 52 | [operationDictionary removeObjectForKey:key]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | 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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewCustomController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewCustomController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/5/23. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewCustomController.h" 10 | #import "HSSetTableViewController.h" 11 | @interface HSSetTableViewCustomController () 12 | 13 | @end 14 | 15 | @implementation HSSetTableViewCustomController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 21 | 22 | HSTitleCellModel *photo = [[HSTitleCellModel alloc] initWithTitle:@"相册" actionBlock:^(HSBaseCellModel *model) { 23 | HSLog(@"点击相册") 24 | }]; 25 | photo.icon = [UIImage imageNamed:@"MoreMyAlbum"]; 26 | [self configureCellModel:&photo]; 27 | 28 | HSTitleCellModel *favorite = [[HSTitleCellModel alloc] initWithTitle:@"收藏" actionBlock:^(HSBaseCellModel *model) { 29 | HSLog(@"点击收藏") 30 | }]; 31 | favorite.icon = [UIImage imageNamed:@"MoreMyFavorites"]; 32 | [self configureCellModel:&favorite]; 33 | 34 | 35 | HSTitleCellModel *wallet = [[HSTitleCellModel alloc] initWithTitle:@"钱包" actionBlock:^(HSBaseCellModel *model) { 36 | HSLog(@"点击钱包") 37 | }]; 38 | wallet.icon = [UIImage imageNamed:@"MoreMyAlbum"]; 39 | [self configureCellModel:&wallet]; 40 | 41 | 42 | HSTitleCellModel *expression = [[HSTitleCellModel alloc] initWithTitle:@"表情" actionBlock:^(HSBaseCellModel *model) { 43 | HSLog(@"点击表情") 44 | }]; 45 | expression.icon = [UIImage imageNamed:@"MoreExpressionShops"]; 46 | [self configureCellModel:&expression]; 47 | 48 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:photo,favorite,wallet,expression, nil]; 49 | [self.hs_dataArry addObject:section0]; 50 | 51 | } 52 | 53 | 54 | //如果每个cell设置的属性都一样,不用每一个设置相同的属性封装一个方法就可以 55 | - (void)configureCellModel:(HSTitleCellModel *__autoreleasing *)baseModel 56 | { 57 | HSTitleCellModel *model = *baseModel; 58 | model.separateColor = [UIColor blueColor]; 59 | model.titleColor = [UIColor redColor]; 60 | model.controlRightOffset = 100; 61 | } 62 | 63 | 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/NSString+HSHeight.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HSHeight.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "NSString+HSHeight.h" 10 | 11 | @implementation NSString (HSHeight) 12 | 13 | 14 | /** 15 | * @brief 计算文字的高度 16 | * 17 | * @param font 字体(默认为系统字体) 18 | * @param width 约束宽度 19 | */ 20 | - (CGFloat)hs_heightWithFont:(UIFont *)font constrainedToWidth:(CGFloat)width 21 | { 22 | UIFont *textFont = font ? font : [UIFont systemFontOfSize:[UIFont systemFontSize]]; 23 | 24 | CGSize textSize; 25 | 26 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 70000 27 | if ([self respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) { 28 | NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; 29 | paragraph.lineBreakMode = NSLineBreakByWordWrapping; 30 | NSDictionary *attributes = @{NSFontAttributeName: textFont, 31 | NSParagraphStyleAttributeName: paragraph}; 32 | textSize = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) 33 | options:(NSStringDrawingUsesLineFragmentOrigin | 34 | NSStringDrawingTruncatesLastVisibleLine) 35 | attributes:attributes 36 | context:nil].size; 37 | } else { 38 | textSize = [self sizeWithFont:textFont 39 | constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) 40 | lineBreakMode:NSLineBreakByWordWrapping]; 41 | } 42 | #else 43 | NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; 44 | paragraph.lineBreakMode = NSLineBreakByWordWrapping; 45 | NSDictionary *attributes = @{NSFontAttributeName: textFont, 46 | NSParagraphStyleAttributeName: paragraph}; 47 | textSize = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) 48 | options:(NSStringDrawingUsesLineFragmentOrigin | 49 | NSStringDrawingTruncatesLastVisibleLine) 50 | attributes:attributes 51 | context:nil].size; 52 | #endif 53 | 54 | return ceil(textSize.height); 55 | } 56 | @end 57 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSTitleCellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSTitleCellModel.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSTitleCellModel.h" 10 | #import "HSSetTableViewControllerConst.h" 11 | #import "NSBundle+HSImage.h" 12 | 13 | @implementation HSTitleCellModel 14 | 15 | 16 | - (instancetype)initWithTitle:(NSString *)title actionBlock:(ClickActionBlock)block; 17 | { 18 | if(self = [super init]){ 19 | self.cellHeight = HS_KCellHeight; 20 | self.title = title; 21 | self.showArrow = YES; 22 | self.actionBlock = block; 23 | self.selectionStyle = UITableViewCellSelectionStyleDefault; 24 | self.separateOffset = HS_KCellMargin; 25 | self.separateColor = HS_KSeparateColor; 26 | self.separateHeight = HS_KSeparateHeight; 27 | self.titleFont = HS_KTitleFont; 28 | self.titleColor = HS_KTitleColor; 29 | self.arrowImage = [NSBundle hs_imageNamed:@"ic_hs_tableView_arrow"]; 30 | self.arrowWidth = HS_KArrowWidth; 31 | self.arrowHeight = HS_kArrowHeight; 32 | self.controlRightOffset = HS_KCellMargin; 33 | self.arrowControlRightOffset = HS_KCellMargin/2; 34 | self.titileTextAlignment = NSTextAlignmentLeft; 35 | } 36 | return self; 37 | } 38 | 39 | - (instancetype)initWithAttributeTitle:(NSAttributedString *)attributeTitle actionBlock:(ClickActionBlock)block 40 | { 41 | if(self = [super init]){ 42 | self.cellHeight = HS_KCellHeight; 43 | self.attributeTitle = attributeTitle; 44 | self.showArrow = YES; 45 | self.actionBlock = block; 46 | self.selectionStyle = UITableViewCellSelectionStyleDefault; 47 | self.separateColor = HS_KSeparateColor; 48 | self.separateHeight = HS_KSeparateHeight; 49 | self.titleFont = HS_KTitleFont; 50 | self.titleColor = HS_KTitleColor; 51 | self.arrowImage = [NSBundle hs_imageNamed:@"ic_hs_tableView_arrow"]; 52 | self.arrowWidth = HS_KArrowWidth; 53 | self.arrowHeight = HS_kArrowHeight; 54 | self.controlRightOffset = HS_KCellMargin; 55 | self.arrowControlRightOffset = HS_KCellMargin/2; 56 | self.titileTextAlignment = NSTextAlignmentLeft; 57 | } 58 | return self; 59 | } 60 | 61 | - (NSString *)cellClass 62 | { 63 | return HSTitleCellModelCellClass; 64 | } 65 | @end 66 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSHeaderTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSHeaderTableViewCell.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSHeaderTableViewCell.h" 10 | #import "UIView+HSFrame.h" 11 | #import "NSBundle+HSImage.h" 12 | #import "HSSetTableViewController.h" 13 | #define KImageWidth 80 14 | 15 | 16 | @interface HSHeaderTableViewCell() 17 | 18 | @property (nonatomic, weak)UILabel *labelTitle; ///<标题 19 | 20 | @end 21 | @implementation HSHeaderTableViewCell 22 | 23 | 24 | - (void)setupUI 25 | { 26 | [super setupUI]; 27 | 28 | UIImageView *header = [[UIImageView alloc] initWithFrame:CGRectMake(10, (100 - KImageWidth)/2, KImageWidth, KImageWidth)]; 29 | header.clipsToBounds = YES; 30 | header.image = [UIImage imageNamed:@"ic_icon_photo"]; 31 | header.layer.cornerRadius = 5.0f; 32 | [self.contentView addSubview:header]; 33 | 34 | 35 | //标题 36 | UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(header.frame)+10, 30, 100, 20)]; 37 | lable.text = @"我的微信名字"; 38 | lable.font = [UIFont systemFontOfSize:15.0f]; 39 | [self.contentView addSubview:lable]; 40 | self.labelTitle = lable; 41 | 42 | 43 | //标题 44 | lable = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(header.frame)+10, CGRectGetMaxY(lable.frame)+10, 200, 20)]; 45 | lable.text = @"微信号:hushaohui"; 46 | lable.font = [UIFont systemFontOfSize:15.0f]; 47 | [self.contentView addSubview:lable]; 48 | 49 | 50 | //添加右边剪头 51 | UIImageView *arrow = [[UIImageView alloc] initWithFrame:CGRectMake(HS_SCREEN_WIDTH-HS_KCellMargin - HS_KArrowWidth, (100 - HS_kArrowHeight)/2, HS_KArrowWidth, HS_kArrowHeight)]; 52 | arrow.image = [NSBundle hs_imageNamed:@"ic_hs_tableView_arrow"]; 53 | [self.contentView addSubview:arrow]; 54 | 55 | //二维码 56 | UIImageView *qrCode = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_icon_qrCode"]]; 57 | qrCode.frame = CGRectMake(HS_SCREEN_WIDTH - HS_KArrowWidth - 2 * HS_KCellMargin - 15 , (100 - 15)/2, 15, 15); 58 | [self.contentView addSubview:qrCode]; 59 | 60 | } 61 | 62 | 63 | //外部model与本界面数据交互 64 | - (void)setupDataModel:(HSBaseCellModel *)model; 65 | { 66 | HSCustomCellModel *custom = (HSCustomCellModel *)model; 67 | self.labelTitle.text = custom.text; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+WebP.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+WebP.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #ifdef SD_WEBP 10 | #import "UIImage+WebP.h" 11 | 12 | #if !COCOAPODS 13 | #import "webp/decode.h" 14 | #else 15 | #import "libwebp/webp/decode.h" 16 | #endif 17 | 18 | // Callback for CGDataProviderRelease 19 | static void FreeImageData(void *info, const void *data, size_t size) 20 | { 21 | free((void *)data); 22 | } 23 | 24 | @implementation UIImage (WebP) 25 | 26 | + (UIImage *)sd_imageWithWebPData:(NSData *)data { 27 | WebPDecoderConfig config; 28 | if (!WebPInitDecoderConfig(&config)) { 29 | return nil; 30 | } 31 | 32 | if (WebPGetFeatures(data.bytes, data.length, &config.input) != VP8_STATUS_OK) { 33 | return nil; 34 | } 35 | 36 | config.output.colorspace = config.input.has_alpha ? MODE_rgbA : MODE_RGB; 37 | config.options.use_threads = 1; 38 | 39 | // Decode the WebP image data into a RGBA value array. 40 | if (WebPDecode(data.bytes, data.length, &config) != VP8_STATUS_OK) { 41 | return nil; 42 | } 43 | 44 | int width = config.input.width; 45 | int height = config.input.height; 46 | if (config.options.use_scaling) { 47 | width = config.options.scaled_width; 48 | height = config.options.scaled_height; 49 | } 50 | 51 | // Construct a UIImage from the decoded RGBA value array. 52 | CGDataProviderRef provider = 53 | CGDataProviderCreateWithData(NULL, config.output.u.RGBA.rgba, config.output.u.RGBA.size, FreeImageData); 54 | CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 55 | CGBitmapInfo bitmapInfo = config.input.has_alpha ? kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast : 0; 56 | size_t components = config.input.has_alpha ? 4 : 3; 57 | CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; 58 | CGImageRef imageRef = CGImageCreate(width, height, 8, components * 8, components * width, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); 59 | 60 | CGColorSpaceRelease(colorSpaceRef); 61 | CGDataProviderRelease(provider); 62 | 63 | UIImage *image = [[UIImage alloc] initWithCGImage:imageRef]; 64 | CGImageRelease(imageRef); 65 | 66 | return image; 67 | } 68 | 69 | @end 70 | 71 | #if !COCOAPODS 72 | // Functions to resolve some undefined symbols when using WebP and force_load flag 73 | void WebPInitPremultiplyNEON(void) {} 74 | void WebPInitUpsamplersNEON(void) {} 75 | void VP8DspInitNEON(void) {} 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/custom/HSZhiHuCustomTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuTableViewCell.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSZhiHuCustomTableViewCell.h" 10 | #import "HSZhiHuCustomCellModel.h" 11 | #import "HSSetTableViewController.h" 12 | #import "NSBundle+HSImage.h" 13 | 14 | @interface HSZhiHuCustomTableViewCell() 15 | 16 | 17 | 18 | @property (nonatomic, weak)UISwitch *mySwitch; ///< 19 | @property (nonatomic, weak)UIImageView *arrow; ///< 20 | @property (nonatomic, strong)HSZhiHuCustomCellModel *switchModel; ///< 21 | 22 | @end 23 | @implementation HSZhiHuCustomTableViewCell 24 | 25 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView 26 | { 27 | HSZhiHuCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 28 | if(cell == nil){ 29 | 30 | //这里重写父类方法 仅仅是因为需要改写下cell样式,实际情况可以自己管理布局 31 | cell = [[HSZhiHuCustomTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 32 | cell.accessoryType = UITableViewCellAccessoryNone; 33 | } 34 | return cell; 35 | } 36 | 37 | - (void)setupUI 38 | { 39 | [super setupUI]; 40 | 41 | 42 | //添加switch 43 | UISwitch *switchItem = [[UISwitch alloc] initWithFrame:CGRectMake(HS_SCREEN_WIDTH- HS_KSwitchWidth - HS_KCellMargin, (60 - HS_KSwitchHeight)/2, HS_KSwitchWidth, HS_KSwitchHeight)]; 44 | [switchItem addTarget:self action:@selector(switchChang:) forControlEvents:UIControlEventValueChanged]; 45 | switchItem.onTintColor = [UIColor blueColor]; 46 | [self.contentView addSubview:switchItem]; 47 | self.mySwitch = switchItem; 48 | 49 | //箭头 50 | UIImageView *arrow = [[UIImageView alloc] initWithFrame:CGRectMake(HS_SCREEN_WIDTH -HS_KCellMargin - HS_KArrowWidth, (60 - HS_kArrowHeight)/2, HS_KArrowWidth, HS_kArrowHeight)]; 51 | arrow.image = [NSBundle hs_imageNamed:@"ic_hs_tableView_arrow"]; 52 | [self.contentView addSubview:arrow]; 53 | self.arrow = arrow; 54 | 55 | } 56 | 57 | - (void)setupDataModel:(HSBaseCellModel *)model 58 | { 59 | [super setupDataModel:model]; 60 | 61 | 62 | HSZhiHuCustomCellModel *cellModel = (HSZhiHuCustomCellModel *)model; 63 | self.switchModel = cellModel; 64 | 65 | self.arrow.hidden = !cellModel.hideSwitch; 66 | self.mySwitch.hidden = cellModel.hideSwitch; 67 | self.textLabel.text = cellModel.text; 68 | self.detailTextLabel.text = cellModel.detailText; 69 | } 70 | 71 | - (void)switchChang:(UISwitch *)switchItem 72 | { 73 | 74 | self.switchModel.on = switchItem.on; 75 | if(self.switchModel.block){ 76 | self.switchModel.block(self.switchModel,switchItem.on); 77 | } 78 | 79 | 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSBaseTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSBaseTableViewCell.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSBaseTableViewCell.h" 10 | #import "HSBaseCellModel.h" 11 | #import "UIColor+HSExtension.h" 12 | #import "UIView+HSFrame.h" 13 | #import "HSSetTableViewControllerConst.h" 14 | #import "NSBundle+HSImage.h" 15 | 16 | 17 | @interface HSBaseTableViewCell() 18 | 19 | 20 | @end 21 | 22 | 23 | @implementation HSBaseTableViewCell 24 | 25 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView; 26 | 27 | { 28 | HSBaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 29 | if(cell == nil){ 30 | cell = [[HSBaseTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 31 | cell.accessoryType = UITableViewCellAccessoryNone; 32 | } 33 | return cell; 34 | } 35 | 36 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 37 | { 38 | if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){ 39 | [self setupUI]; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)setupUI 45 | { 46 | //添加顶部分割线 47 | CALayer *topLine = [CALayer layer]; 48 | [topLine setFrame:CGRectMake(0, 0, self.frame.size.width, HS_KSeparateHeight)]; 49 | [topLine setBackgroundColor:HS_KSeparateColor.CGColor]; 50 | [self.contentView.layer addSublayer:topLine]; 51 | self.topLine = topLine; 52 | 53 | //添加底部分割线 54 | CALayer *bottomLine = [CALayer layer]; 55 | [bottomLine setFrame:CGRectMake(0, 0, self.frame.size.width, HS_KSeparateHeight)]; 56 | [bottomLine setBackgroundColor:HS_KSeparateColor.CGColor]; 57 | [self.contentView.layer addSublayer:bottomLine]; 58 | self.bottomLine = bottomLine; 59 | 60 | 61 | } 62 | 63 | - (void)setupDataModel:(HSBaseCellModel *)model 64 | { 65 | self.cellModel = model; 66 | self.selectionStyle = model.selectionStyle; 67 | [self.bottomLine setHs_y:model.cellHeight - model.separateHeight]; 68 | [self.bottomLine setHs_height:model.separateHeight]; 69 | [self.topLine setHs_height:model.separateHeight]; 70 | [self.bottomLine setBackgroundColor:model.separateColor.CGColor]; 71 | [self.topLine setBackgroundColor:model.separateColor.CGColor]; 72 | } 73 | 74 | 75 | - (void)layoutSubviews 76 | { 77 | [super layoutSubviews]; 78 | [self.bottomLine setHs_width:self.frame.size.width]; 79 | [self.topLine setHs_width:self.frame.size.width]; 80 | } 81 | 82 | 83 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 84 | [super setSelected:selected animated:animated]; 85 | } 86 | 87 | + (CGFloat)getCellHeight:(HSBaseCellModel *)model 88 | { 89 | return model.cellHeight; 90 | } 91 | 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | extern NSString *const SDWebImageDownloadStartNotification; 14 | extern NSString *const SDWebImageDownloadReceiveResponseNotification; 15 | extern NSString *const SDWebImageDownloadStopNotification; 16 | extern NSString *const SDWebImageDownloadFinishNotification; 17 | 18 | @interface SDWebImageDownloaderOperation : NSOperation 19 | 20 | /** 21 | * The request used by the operation's connection. 22 | */ 23 | @property (strong, nonatomic, readonly) NSURLRequest *request; 24 | 25 | 26 | @property (assign, nonatomic) BOOL shouldDecompressImages; 27 | 28 | /** 29 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 30 | * 31 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 32 | */ 33 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 34 | 35 | /** 36 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 37 | * 38 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 39 | */ 40 | @property (nonatomic, strong) NSURLCredential *credential; 41 | 42 | /** 43 | * The SDWebImageDownloaderOptions for the receiver. 44 | */ 45 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 46 | 47 | /** 48 | * The expected size of data. 49 | */ 50 | @property (assign, nonatomic) NSInteger expectedSize; 51 | 52 | /** 53 | * The response returned by the operation's connection. 54 | */ 55 | @property (strong, nonatomic) NSURLResponse *response; 56 | 57 | /** 58 | * Initializes a `SDWebImageDownloaderOperation` object 59 | * 60 | * @see SDWebImageDownloaderOperation 61 | * 62 | * @param request the URL request 63 | * @param options downloader options 64 | * @param progressBlock the block executed when a new chunk of data arrives. 65 | * @note the progress block is executed on a background queue 66 | * @param completedBlock the block executed when the download is done. 67 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue 68 | * @param cancelBlock the block executed if the download (operation) is cancelled 69 | * 70 | * @return the initialized instance 71 | */ 72 | - (id)initWithRequest:(NSURLRequest *)request 73 | options:(SDWebImageDownloaderOptions)options 74 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 75 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 76 | cancelled:(SDWebImageNoParamsBlock)cancelBlock; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSZhiHuTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSZhiHuTableViewController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSZhiHuTableViewController.h" 10 | #import "HSSetTableViewController.h" 11 | #import "HSZhiHuCustomCellModel.h" 12 | @interface HSZhiHuTableViewController () 13 | 14 | @end 15 | 16 | @implementation HSZhiHuTableViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 22 | self.title = @"知乎设置界面"; 23 | 24 | // //内置音效 25 | HSZhiHuCustomCellModel *sound = [[HSZhiHuCustomCellModel alloc] initWithCellIdentifier:@"HSZhiHuCustomTableViewCell" actionBlock:nil]; 26 | sound.cellHeight = 60; 27 | sound.text = @"内置音效"; 28 | sound.detailText = @"应用内按钮点击音效"; 29 | sound.hideSwitch = NO; 30 | sound.selectionStyle = UITableViewCellSelectionStyleNone; 31 | 32 | 33 | HSZhiHuCustomCellModel *noIcon = [[HSZhiHuCustomCellModel alloc] initWithCellIdentifier:@"HSZhiHuCustomTableViewCell" actionBlock:nil]; 34 | noIcon.cellHeight = 60; 35 | noIcon.text = @"无图模式"; 36 | noIcon.detailText = @"使用wifi网络时不可下载图片"; 37 | noIcon.hideSwitch = NO; 38 | noIcon.selectionStyle = UITableViewCellSelectionStyleNone; 39 | 40 | 41 | HSZhiHuCustomCellModel *titleFont = [[HSZhiHuCustomCellModel alloc] initWithCellIdentifier:@"HSZhiHuCustomTableViewCell" actionBlock:nil]; 42 | titleFont.cellHeight = 60; 43 | titleFont.text = @"字体大小"; 44 | titleFont.detailText = @"除回答与专栏正文页面以外的字体调节"; 45 | titleFont.hideSwitch = YES; 46 | 47 | 48 | 49 | //消息通知 50 | HSTitleCellModel *msg = [[HSTitleCellModel alloc] initWithTitle:@"消息与邮件设置" actionBlock:nil]; 51 | //聊天记录 52 | HSTitleCellModel *record = [[HSTitleCellModel alloc] initWithTitle:@"推送消息设置" actionBlock:nil]; 53 | //空间清理 54 | HSTitleCellModel *clean = [[HSTitleCellModel alloc] initWithTitle:@"账号与安全" actionBlock:nil]; 55 | //消息通知 56 | HSTitleCellModel *security = [[HSTitleCellModel alloc] initWithTitle:@"管理黑名单" actionBlock:nil]; 57 | //聊天记录 58 | HSTextCellModel *privacy = [[HSTextCellModel alloc] initWithTitle:@"清除缓存" detailText:@"0.85M" actionBlock:nil]; 59 | privacy.showArrow = NO; 60 | 61 | //空间清理 62 | HSTitleCellModel *help = [[HSTitleCellModel alloc] initWithTitle:@"知乎实验室" actionBlock:nil]; 63 | //关于QQ与帮助 64 | HSTitleCellModel *about = [[HSTitleCellModel alloc] initWithTitle:@"退出我的账号" actionBlock:nil]; 65 | about.showArrow = NO; 66 | about.titleColor = [UIColor redColor]; 67 | about.titileTextAlignment = NSTextAlignmentCenter; 68 | 69 | NSMutableArray *section = [NSMutableArray arrayWithObjects:sound,noIcon,titleFont,nil]; 70 | NSMutableArray *section1 = [NSMutableArray arrayWithObjects:msg, record,nil]; 71 | NSMutableArray *section2 = [NSMutableArray arrayWithObjects:clean,nil]; 72 | NSMutableArray *section3 = [NSMutableArray arrayWithObjects:security, privacy,help,nil]; 73 | NSMutableArray *section4 = [NSMutableArray arrayWithObjects:about,nil]; 74 | [self.hs_dataArry addObject:section]; 75 | [self.hs_dataArry addObject:section1]; 76 | [self.hs_dataArry addObject:section2]; 77 | [self.hs_dataArry addObject:section3]; 78 | [self.hs_dataArry addObject:section4]; 79 | [self.hs_tableView reloadData]; 80 | } 81 | 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/22. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HSSetTableViewMeController.h" 11 | #import "HSSetTableInfoController.h" 12 | #import "HSSetTableViewOtherController.h" 13 | #import "HSSetTableViewQQController.h" 14 | #import "HSSetTableViewCustomController.h" 15 | #import "HSZhiHuTableViewController.h" 16 | #import "HSCategoryViewController.h" 17 | @interface ViewController () 18 | @property (nonatomic, weak)UITableView *tableView; ///< 19 | @property (nonatomic, strong)NSArray *dataSource; ///< 20 | @property (nonatomic, strong)NSArray *classSource; ///< 21 | 22 | @end 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | self.title = @"HSSetTableViewControllerDemo"; 29 | 30 | CGRect frame = self.view.bounds; 31 | UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain]; 32 | tableView.backgroundColor = [UIColor clearColor]; 33 | tableView.delegate = self; 34 | tableView.dataSource =self; 35 | tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 36 | tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 37 | tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; 38 | 39 | if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_8_x_Max){ 40 | tableView.cellLayoutMarginsFollowReadableWidth = NO; 41 | } 42 | 43 | // tableView.cellLayoutMarginsFollowReadableWidth = NO; 44 | [self.view addSubview:tableView]; 45 | self.tableView = tableView; 46 | self.dataSource = @[@"我(仿微信)",@"个人信息(仿微信)",@"复杂界面(更新)",@"个人资料(QQ)",@"统一风格(自定义)",@"知乎(包含自定义cell)",@"控制器分类"]; 47 | self.classSource = @[@"HSSetTableViewMeController",@"HSSetTableInfoController",@"HSSetTableViewOtherController",@"HSSetTableViewQQController",@"HSSetTableViewCustomController",@"HSZhiHuTableViewController",@"HSCategoryViewController"]; 48 | } 49 | 50 | 51 | 52 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 53 | { 54 | static NSString *cellIdentifier = @"cellIdentifier"; 55 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 56 | if(cell == nil){ 57 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 58 | } 59 | cell.textLabel.text = [self.dataSource objectAtIndex:indexPath.row]; 60 | return cell; 61 | } 62 | 63 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 64 | { 65 | return self.dataSource.count; 66 | } 67 | 68 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 69 | { 70 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 71 | 72 | NSString *ctroller = [self.classSource objectAtIndex:indexPath.row]; 73 | Class class = NSClassFromString(ctroller); 74 | UIViewController *view = [[class alloc] init]; 75 | view.title = [self.dataSource objectAtIndex:indexPath.row]; 76 | [self.navigationController pushViewController:view animated:YES]; 77 | } 78 | 79 | 80 | - (void)didReceiveMemoryWarning { 81 | [super didReceiveMemoryWarning]; 82 | } 83 | 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSSwitchTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowSwitchRightCell.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSwitchTableViewCell.h" 10 | #import "HSSetTableViewControllerConst.h" 11 | #import "HSSwitchCellModel.h" 12 | #import "UIView+HSFrame.h" 13 | 14 | @interface HSSwitchTableViewCell() 15 | @property (nonatomic, weak)UISwitch *switchItem; ///<开关 16 | 17 | @property (nonatomic, weak)NSLayoutConstraint *switchRightConstaint; ///< 18 | @end 19 | 20 | @implementation HSSwitchTableViewCell 21 | 22 | //cell初始化方法 23 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView; 24 | { 25 | HSSwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 26 | if(cell == nil){ 27 | cell = [[HSSwitchTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 28 | cell.accessoryType = UITableViewCellAccessoryNone; 29 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 30 | } 31 | return cell; 32 | } 33 | 34 | - (void)setupUI 35 | { 36 | [super setupUI]; 37 | //添加开关控件 38 | UISwitch *switchItem = [[UISwitch alloc] initWithFrame:CGRectZero]; 39 | [switchItem addTarget:self action:@selector(switchChang:) forControlEvents:UIControlEventValueChanged]; 40 | switchItem.translatesAutoresizingMaskIntoConstraints = NO; 41 | [self.contentView addSubview:switchItem]; 42 | self.switchItem = switchItem; 43 | 44 | [self setupSwitchItemConstrnts]; 45 | } 46 | 47 | - (void)setupSwitchItemConstrnts 48 | { 49 | 50 | NSLayoutConstraint *switchRightConstaint = [NSLayoutConstraint constraintWithItem:self.switchItem attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant: -HS_KCellMargin]; 51 | [self.contentView addConstraint:switchRightConstaint]; 52 | self.switchRightConstaint = switchRightConstaint; 53 | 54 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.switchItem attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 55 | 56 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.switchItem attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_KSwitchWidth]]; 57 | 58 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.switchItem attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_KSwitchHeight]]; 59 | } 60 | 61 | - (void)setupDataModel:(HSBaseCellModel *)model 62 | { 63 | [super setupDataModel:model]; 64 | HSSwitchCellModel *switchModel = (HSSwitchCellModel *)model; 65 | self.switchItem.on = switchModel.on; 66 | if(switchModel.onTintColor){ 67 | self.switchItem.onTintColor = switchModel.onTintColor; 68 | } 69 | self.switchRightConstaint.constant = - switchModel.controlRightOffset; 70 | 71 | } 72 | 73 | - (void)switchChang:(UISwitch *)switchItem 74 | { 75 | HSSwitchCellModel *model = 76 | (HSSwitchCellModel *)self.cellModel; 77 | model.on = switchItem.on; 78 | if(model.switchBlock){ 79 | model.switchBlock(self.cellModel,switchItem.on); 80 | } 81 | 82 | 83 | } 84 | 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /HSSetTableViewController/Category/UIView+HSFrame.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HSFrame.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/18. 6 | // Cohsright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "UIView+HSFrame.h" 10 | 11 | @implementation UIView (HSFrame) 12 | 13 | - (void)setHs_x:(CGFloat)hs_x 14 | { 15 | CGRect frame = self.frame; 16 | frame.origin.x = hs_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)hs_x 21 | { 22 | return self.frame.origin.x; 23 | } 24 | 25 | - (void)setHs_centerX:(CGFloat)hs_centerX 26 | { 27 | CGPoint center = self.center; 28 | center.x = hs_centerX; 29 | self.center = center; 30 | } 31 | 32 | - (CGFloat)hs_centerX 33 | { 34 | return self.center.x; 35 | } 36 | 37 | -(void)setHs_centerY:(CGFloat)hs_centerY 38 | { 39 | CGPoint center = self.center; 40 | center.y = hs_centerY; 41 | self.center = center; 42 | } 43 | 44 | - (CGFloat)hs_centerY 45 | { 46 | return self.center.y; 47 | } 48 | 49 | - (void)setHs_y:(CGFloat)hs_y 50 | { 51 | CGRect frame = self.frame; 52 | frame.origin.y = hs_y; 53 | self.frame = frame; 54 | } 55 | 56 | - (CGFloat)hs_y 57 | { 58 | return self.frame.origin.y; 59 | } 60 | 61 | - (void)setHs_size:(CGSize)hs_size 62 | { 63 | CGRect frame = self.frame; 64 | frame.size = hs_size; 65 | self.frame = frame; 66 | 67 | } 68 | 69 | - (CGSize)hs_size 70 | { 71 | return self.frame.size; 72 | } 73 | 74 | - (void)setHs_height:(CGFloat)hs_height 75 | { 76 | CGRect frame = self.frame; 77 | frame.size.height = hs_height; 78 | self.frame = frame; 79 | } 80 | 81 | - (CGFloat)hs_height 82 | { 83 | return self.frame.size.height; 84 | } 85 | 86 | - (void)setHs_width:(CGFloat)hs_width 87 | { 88 | CGRect frame = self.frame; 89 | frame.size.width = hs_width; 90 | self.frame = frame; 91 | 92 | } 93 | 94 | -(CGFloat)hs_width 95 | { 96 | return self.frame.size.width; 97 | } 98 | 99 | - (void)setHs_origin:(CGPoint)hs_origin 100 | { 101 | CGRect frame = self.frame; 102 | frame.origin = hs_origin; 103 | self.frame = frame; 104 | } 105 | 106 | - (CGPoint)Hs_origin 107 | { 108 | return self.frame.origin; 109 | } 110 | 111 | @end 112 | 113 | @implementation CALayer(HSFrame) 114 | 115 | - (void)setHs_x:(CGFloat)hs_x 116 | { 117 | CGRect frame = self.frame; 118 | frame.origin.x = hs_x; 119 | self.frame = frame; 120 | } 121 | 122 | - (CGFloat)hs_x 123 | { 124 | return self.frame.origin.x; 125 | } 126 | 127 | - (void)setHs_y:(CGFloat)hs_y 128 | { 129 | CGRect frame = self.frame; 130 | frame.origin.y = hs_y; 131 | self.frame = frame; 132 | } 133 | 134 | - (CGFloat)hs_y 135 | { 136 | return self.frame.origin.y; 137 | } 138 | 139 | - (void)setHs_size:(CGSize)hs_size 140 | { 141 | CGRect frame = self.frame; 142 | frame.size = hs_size; 143 | self.frame = frame; 144 | 145 | } 146 | 147 | - (CGSize)hs_size 148 | { 149 | return self.frame.size; 150 | } 151 | 152 | - (void)setHs_height:(CGFloat)hs_height 153 | { 154 | CGRect frame = self.frame; 155 | frame.size.height = hs_height; 156 | self.frame = frame; 157 | } 158 | 159 | - (CGFloat)hs_height 160 | { 161 | return self.frame.size.height; 162 | } 163 | 164 | - (void)setHs_width:(CGFloat)hs_width 165 | { 166 | CGRect frame = self.frame; 167 | frame.size.width = hs_width; 168 | self.frame = frame; 169 | 170 | } 171 | 172 | -(CGFloat)hs_width 173 | { 174 | return self.frame.size.width; 175 | } 176 | 177 | 178 | 179 | @end 180 | 181 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSTextTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowTextRightCell.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/19. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSTextTableViewCell.h" 10 | #import "HSTextCellModel.h" 11 | #import "HSSetTableViewControllerConst.h" 12 | #import "UIView+HSFrame.h" 13 | @interface HSTextTableViewCell() 14 | 15 | @property (nonatomic, weak)UILabel *detailLabel; ///<详细文本内容 16 | @property (nonatomic, weak)NSLayoutConstraint *detailRightConstraint; ///< 17 | @property (nonatomic, weak)NSLayoutConstraint *detailLeftConstraint; ///< 18 | @end 19 | @implementation HSTextTableViewCell 20 | 21 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView; 22 | { 23 | HSTextTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 24 | if(cell == nil){ 25 | cell = [[HSTextTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 26 | cell.accessoryType = UITableViewCellAccessoryNone; 27 | } 28 | return cell; 29 | } 30 | - (void)setupUI 31 | { 32 | //先实现super调用 33 | [super setupUI]; 34 | //添加右边label 35 | UILabel *detailTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 36 | detailTextLabel.numberOfLines = 0; 37 | detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO; 38 | detailTextLabel.textAlignment = NSTextAlignmentRight; 39 | [self.contentView addSubview:detailTextLabel]; 40 | self.detailLabel = detailTextLabel; 41 | [self setupdetailLabelConstraints]; 42 | } 43 | 44 | - (void)setupdetailLabelConstraints 45 | { 46 | 47 | NSLayoutConstraint *constraintRight = [NSLayoutConstraint constraintWithItem:self.detailLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-HS_KCellMargin-HS_KCellMargin/2 - HS_KArrowWidth]; 48 | [self.contentView addConstraint:constraintRight]; 49 | self.detailRightConstraint = constraintRight; 50 | 51 | 52 | NSLayoutConstraint *constraintLeft = [NSLayoutConstraint constraintWithItem:self.detailLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:HS_KCellTextLeftPading]; 53 | [self.contentView addConstraint:constraintLeft]; 54 | self.detailLeftConstraint = constraintLeft; 55 | 56 | 57 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.detailLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 58 | } 59 | 60 | 61 | 62 | - (void)setupDataModel:(HSBaseCellModel *)model 63 | { 64 | [super setupDataModel:model]; 65 | 66 | HSTextCellModel *rightModel = (HSTextCellModel *)model; 67 | if(rightModel.attributeDetailText){ 68 | self.detailLabel.numberOfLines = 1; 69 | self.detailLabel.attributedText = rightModel.attributeDetailText; 70 | }else{ 71 | self.detailLabel.numberOfLines = 0; 72 | self.detailLabel.text = rightModel.detailText; 73 | self.detailLabel.textColor = rightModel.detailColor ; 74 | self.detailLabel.font = rightModel.detailFont; 75 | } 76 | 77 | //根据箭头显示设置约束 78 | if(rightModel.showArrow){ 79 | self.detailRightConstraint.constant = - rightModel.controlRightOffset - rightModel.arrowControlRightOffset - rightModel.arrowWidth; 80 | }else{ 81 | self.detailRightConstraint.constant = - rightModel.controlRightOffset; 82 | } 83 | self.detailLeftConstraint.constant = rightModel.leftPading; 84 | } 85 | 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSCategoryViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSCategoryViewController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/7/24. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSCategoryViewController.h" 10 | #import "HSSetTableInfoController.h" 11 | #import "UIViewController+HSSetTableView.h" 12 | @interface HSCategoryViewController () 13 | 14 | @end 15 | 16 | @implementation HSCategoryViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 22 | self.title = @"个人信息"; 23 | 24 | [self initSetTableViewConfigureStyle:UITableViewStylePlain]; 25 | 26 | 27 | //头像 28 | UIImage *icon = [UIImage imageNamed:@"ic_icon_header"]; 29 | HSImageCellModel *header = [[HSImageCellModel alloc] initWithTitle:@"头像" placeholderImage:icon imageUrl:nil actionBlock:^(HSBaseCellModel *model) { 30 | 31 | } imageBlock:^(HSBaseCellModel *cellModel) { 32 | HSLog(@"点击头像--%@",cellModel) 33 | }]; 34 | 35 | //名字 36 | HSTextCellModel *name = [[HSTextCellModel alloc] initWithTitle:@"名字" detailText:@"人名的名义" actionBlock:^(HSBaseCellModel *model) { 37 | 38 | }]; 39 | 40 | 41 | 42 | //微信号 43 | HSTextCellModel *number = [[HSTextCellModel alloc] initWithTitle:@"微信号" detailText:@"HSSetTableView" actionBlock:^(HSBaseCellModel *model) { 44 | 45 | }]; 46 | number.selectionStyle = UITableViewCellSelectionStyleNone; 47 | number.showArrow = NO; 48 | 49 | //我的二维码 50 | UIImage *image = [UIImage imageNamed:@"ic_icon_qrCode"]; 51 | HSImageCellModel *qrCode = [[HSImageCellModel alloc] initWithTitle:@"我的二维码" placeholderImage:image imageUrl:nil actionBlock:^(HSBaseCellModel *model) { 52 | 53 | } imageBlock:nil]; 54 | qrCode.imageSize = CGSizeMake(15, 15); 55 | qrCode.cellHeight = HS_KCellHeight; 56 | 57 | //我的地址 58 | HSTitleCellModel *address = [[HSTitleCellModel alloc] initWithTitle:@"我的地址" actionBlock:^(HSBaseCellModel *model) { 59 | 60 | }]; 61 | 62 | //性别 63 | HSTextCellModel *sex = [[HSTextCellModel alloc] initWithTitle:@"性别" detailText:@"男" actionBlock:nil]; 64 | 65 | //地区 66 | HSTextCellModel *area = [[HSTextCellModel alloc] initWithTitle:@"地区" detailText:@"四川 成都" actionBlock:nil]; 67 | // 68 | // 69 | //个性签名 70 | HSTextCellModel *sign = [[HSTextCellModel alloc] initWithTitle:@"签名" detailText:@"气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹" actionBlock:nil]; 71 | // sign.controlRightOffset = 30; 72 | // sign.arrowControlRightOffset = 50; 73 | 74 | 75 | 76 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:header,name,number,qrCode,address, nil]; 77 | NSMutableArray *section1 = [NSMutableArray arrayWithObjects:area,sex,sign,nil]; 78 | [self.hs_dataArry addObject:section0]; 79 | [self.hs_dataArry addObject:section1]; 80 | [self.hs_tableView reloadData]; 81 | } 82 | 83 | - (void)didReceiveMemoryWarning { 84 | [super didReceiveMemoryWarning]; 85 | // Dispose of any resources that can be recreated. 86 | } 87 | 88 | - (void)dealloc 89 | { 90 | NSLog(@"%@销毁",self.class); 91 | } 92 | 93 | /* 94 | #pragma mark - Navigation 95 | 96 | // In a storyboard-based application, you will often want to do a little preparation before navigation 97 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 98 | // Get the new view controller using [segue destinationViewController]. 99 | // Pass the selected object to the new view controller. 100 | } 101 | */ 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "UIImage+GIF.h" 11 | #import "NSData+ImageContentType.h" 12 | #import 13 | 14 | #ifdef SD_WEBP 15 | #import "UIImage+WebP.h" 16 | #endif 17 | 18 | @implementation UIImage (MultiFormat) 19 | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { 21 | if (!data) { 22 | return nil; 23 | } 24 | 25 | UIImage *image; 26 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; 27 | if ([imageContentType isEqualToString:@"image/gif"]) { 28 | image = [UIImage sd_animatedGIFWithData:data]; 29 | } 30 | #ifdef SD_WEBP 31 | else if ([imageContentType isEqualToString:@"image/webp"]) 32 | { 33 | image = [UIImage sd_imageWithWebPData:data]; 34 | } 35 | #endif 36 | else { 37 | image = [[UIImage alloc] initWithData:data]; 38 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 39 | if (orientation != UIImageOrientationUp) { 40 | image = [UIImage imageWithCGImage:image.CGImage 41 | scale:image.scale 42 | orientation:orientation]; 43 | } 44 | } 45 | 46 | 47 | return image; 48 | } 49 | 50 | 51 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { 52 | UIImageOrientation result = UIImageOrientationUp; 53 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 54 | if (imageSource) { 55 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 56 | if (properties) { 57 | CFTypeRef val; 58 | int exifOrientation; 59 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 60 | if (val) { 61 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 62 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 63 | } // else - if it's not set it remains at up 64 | CFRelease((CFTypeRef) properties); 65 | } else { 66 | //NSLog(@"NO PROPERTIES, FAIL"); 67 | } 68 | CFRelease(imageSource); 69 | } 70 | return result; 71 | } 72 | 73 | #pragma mark EXIF orientation tag converter 74 | // Convert an EXIF image orientation to an iOS one. 75 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 76 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 77 | UIImageOrientation orientation = UIImageOrientationUp; 78 | switch (exifOrientation) { 79 | case 1: 80 | orientation = UIImageOrientationUp; 81 | break; 82 | 83 | case 3: 84 | orientation = UIImageOrientationDown; 85 | break; 86 | 87 | case 8: 88 | orientation = UIImageOrientationLeft; 89 | break; 90 | 91 | case 6: 92 | orientation = UIImageOrientationRight; 93 | break; 94 | 95 | case 2: 96 | orientation = UIImageOrientationUpMirrored; 97 | break; 98 | 99 | case 4: 100 | orientation = UIImageOrientationDownMirrored; 101 | break; 102 | 103 | case 5: 104 | orientation = UIImageOrientationLeftMirrored; 105 | break; 106 | 107 | case 7: 108 | orientation = UIImageOrientationRightMirrored; 109 | break; 110 | default: 111 | break; 112 | } 113 | return orientation; 114 | } 115 | 116 | 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewMeController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewMeController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewMeController.h" 10 | #import "HSSetTableViewController.h" 11 | #import "HSCustomCellModel.h" 12 | #import "HSHeaderCellModel.h" 13 | 14 | @interface HSSetTableViewMeController () 15 | 16 | @end 17 | 18 | @implementation HSSetTableViewMeController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | 24 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 25 | 26 | 27 | __weak __typeof(&*self)weakSelf = self; 28 | HSHeaderCellModel *header = [[HSHeaderCellModel alloc] initWithCellIdentifier:@"HSHeaderTableViewCell" actionBlock:^(HSBaseCellModel *model) { 29 | HSHeaderCellModel *hederModel = (HSHeaderCellModel *)model; 30 | hederModel.text = @"奔跑吧,兄弟"; 31 | [weakSelf updateCellModel:hederModel]; 32 | }]; 33 | header.text = @"天霸动霸tuo"; 34 | header.cellHeight = 100; 35 | 36 | HSTitleCellModel *photo = [[HSTitleCellModel alloc] initWithTitle:@"相册" actionBlock:^(HSBaseCellModel *model) { 37 | HSLog(@"点击相册") 38 | }]; 39 | photo.icon = [UIImage imageNamed:@"MoreMyAlbum"]; 40 | 41 | HSTitleCellModel *favorite = [[HSTitleCellModel alloc] initWithTitle:@"收藏" actionBlock:^(HSBaseCellModel *model) { 42 | HSLog(@"点击收藏") 43 | }]; 44 | favorite.icon = [UIImage imageNamed:@"MoreMyFavorites"]; 45 | 46 | 47 | HSTitleCellModel *wallet = [[HSTitleCellModel alloc] initWithTitle:@"钱包" actionBlock:^(HSBaseCellModel *model) { 48 | HSLog(@"点击钱包") 49 | }]; 50 | wallet.icon = [UIImage imageNamed:@"MoreMyAlbum"]; 51 | 52 | 53 | HSTitleCellModel *expression = [[HSTitleCellModel alloc] initWithTitle:@"表情" actionBlock:^(HSBaseCellModel *model) { 54 | HSLog(@"点击表情") 55 | }]; 56 | expression.icon = [UIImage imageNamed:@"MoreExpressionShops"]; 57 | 58 | HSTitleCellModel *setting = [[HSTitleCellModel alloc] initWithTitle:@"设置" actionBlock:^(HSBaseCellModel *model) { 59 | HSLog(@"点击设置") 60 | }]; 61 | setting.icon = [UIImage imageNamed:@"MoreExpressionShops"]; 62 | NSMutableArray *section = [NSMutableArray arrayWithObjects:header,nil]; 63 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:photo,favorite,wallet, nil]; 64 | NSMutableArray *section1 = [NSMutableArray arrayWithObjects:expression,nil]; 65 | NSMutableArray *section2 = [NSMutableArray arrayWithObjects:setting,nil]; 66 | 67 | [self.hs_dataArry addObject:section]; 68 | [self.hs_dataArry addObject:section0]; 69 | [self.hs_dataArry addObject:section1]; 70 | [self.hs_dataArry addObject:section2]; 71 | 72 | 73 | [self.hs_tableView reloadData]; 74 | 75 | // self.tableView.tableHeaderView = [self viewTableHeader]; 76 | 77 | } 78 | 79 | - (UIView *)viewTableHeader 80 | { 81 | UIView *viewHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, HS_SCREEN_WIDTH, 100)]; 82 | [viewHeader setBackgroundColor:[UIColor redColor]]; 83 | return viewHeader; 84 | } 85 | 86 | #pragma mark tableView代理方法,重写基类footer方法 87 | //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section; 88 | //{ 89 | // return 50; 90 | //} 91 | // 92 | //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; 93 | //{ 94 | // UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; 95 | // [view setBackgroundColor:[UIColor hs_colorWithHexString:@"#EBEDEF"]]; 96 | // return view; 97 | //} 98 | 99 | - (void)dealloc 100 | { 101 | NSLog(@"%@控制器销毁",self.class); 102 | } 103 | 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /HSSetTableViewController/Model/HSTitleTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSTitleTableViewCell.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/6/9. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSTitleTableViewCell.h" 10 | #import "HSTitleCellModel.h" 11 | #import "UIView+HSFrame.h" 12 | #import "HSSetTableViewControllerConst.h" 13 | 14 | @interface HSTitleTableViewCell() 15 | @property (nonatomic, weak)NSLayoutConstraint *arrowWidthContraint; ///<箭头宽度contraint 16 | @property (nonatomic, weak)NSLayoutConstraint *arrowHeightContraint; ///<箭头高度contraint 17 | @property (nonatomic, weak)NSLayoutConstraint *arrowRightContraint; ///<箭头距右边contraint 18 | 19 | @end 20 | @implementation HSTitleTableViewCell 21 | 22 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView; 23 | { 24 | HSTitleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 25 | if(cell == nil){ 26 | cell = [[HSTitleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 27 | cell.accessoryType = UITableViewCellAccessoryNone; 28 | } 29 | return cell; 30 | } 31 | 32 | - (void)setupUI 33 | { 34 | [super setupUI]; 35 | //添加右边剪头 36 | UIImageView *arrow = [[UIImageView alloc] init]; 37 | arrow.frame = CGRectZero; 38 | arrow.translatesAutoresizingMaskIntoConstraints = NO; 39 | [self.contentView addSubview:arrow]; 40 | self.arrow = arrow; 41 | [self setupArrowImageConstraints];//设置图片约束 42 | } 43 | 44 | - (void)setupArrowImageConstraints 45 | { 46 | 47 | NSLayoutConstraint *arrowRightContraint = [NSLayoutConstraint constraintWithItem:self.arrow attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-HS_KCellMargin]; 48 | [self.contentView addConstraint:arrowRightContraint]; 49 | self.arrowRightContraint = arrowRightContraint; 50 | 51 | 52 | NSLayoutConstraint *arrowWidthContraint = [NSLayoutConstraint constraintWithItem:self.arrow attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_KArrowWidth]; 53 | [self.contentView addConstraint:arrowWidthContraint]; 54 | self.arrowWidthContraint = arrowWidthContraint; 55 | 56 | 57 | NSLayoutConstraint *arrowHeightContraint = [NSLayoutConstraint constraintWithItem:self.arrow attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_kArrowHeight]; 58 | 59 | [self.contentView addConstraint:arrowHeightContraint]; 60 | self.arrowHeightContraint = arrowHeightContraint; 61 | 62 | 63 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.arrow attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 64 | } 65 | 66 | - (void)setupDataModel:(HSBaseCellModel *)model 67 | { 68 | [super setupDataModel:model]; 69 | 70 | HSTitleCellModel *cellMoldel = (HSTitleCellModel *)model; 71 | if(cellMoldel.attributeTitle){ 72 | self.textLabel.attributedText = cellMoldel.attributeTitle; 73 | }else{ 74 | self.textLabel.text = cellMoldel.title; 75 | self.textLabel.textColor = cellMoldel.titleColor; 76 | self.textLabel.font = cellMoldel.titleFont; 77 | } 78 | self.textLabel.textAlignment = cellMoldel.titileTextAlignment; 79 | self.imageView.image = cellMoldel.icon; 80 | 81 | self.backgroundColor = model.backgroundColor?:[UIColor whiteColor]; 82 | self.arrow.hidden = !cellMoldel.showArrow; 83 | self.selectionStyle = cellMoldel.selectionStyle; 84 | self.arrow.image = cellMoldel.arrowImage; 85 | 86 | self.arrowWidthContraint.constant = cellMoldel.arrowWidth; 87 | self.arrowHeightContraint.constant = cellMoldel.arrowHeight; 88 | self.arrowRightContraint.constant = - cellMoldel.controlRightOffset; 89 | 90 | } 91 | 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImageDecoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import "SDWebImageDecoder.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 16 | // while downloading huge amount of images 17 | // autorelease the bitmap context 18 | // and all vars to help system to free memory 19 | // when there are memory warning. 20 | // on iOS7, do not forget to call 21 | // [[SDImageCache sharedImageCache] clearMemory]; 22 | 23 | if (image == nil) { // Prevent "CGBitmapContextCreateImage: invalid context 0x0" error 24 | return nil; 25 | } 26 | 27 | @autoreleasepool{ 28 | // do not decode animated images 29 | if (image.images != nil) { 30 | return image; 31 | } 32 | 33 | CGImageRef imageRef = image.CGImage; 34 | 35 | CGImageAlphaInfo alpha = CGImageGetAlphaInfo(imageRef); 36 | BOOL anyAlpha = (alpha == kCGImageAlphaFirst || 37 | alpha == kCGImageAlphaLast || 38 | alpha == kCGImageAlphaPremultipliedFirst || 39 | alpha == kCGImageAlphaPremultipliedLast); 40 | if (anyAlpha) { 41 | return image; 42 | } 43 | 44 | // current 45 | CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef)); 46 | CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef); 47 | 48 | BOOL unsupportedColorSpace = (imageColorSpaceModel == kCGColorSpaceModelUnknown || 49 | imageColorSpaceModel == kCGColorSpaceModelMonochrome || 50 | imageColorSpaceModel == kCGColorSpaceModelCMYK || 51 | imageColorSpaceModel == kCGColorSpaceModelIndexed); 52 | if (unsupportedColorSpace) { 53 | colorspaceRef = CGColorSpaceCreateDeviceRGB(); 54 | } 55 | 56 | size_t width = CGImageGetWidth(imageRef); 57 | size_t height = CGImageGetHeight(imageRef); 58 | NSUInteger bytesPerPixel = 4; 59 | NSUInteger bytesPerRow = bytesPerPixel * width; 60 | NSUInteger bitsPerComponent = 8; 61 | 62 | 63 | // kCGImageAlphaNone is not supported in CGBitmapContextCreate. 64 | // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipLast 65 | // to create bitmap graphics contexts without alpha info. 66 | CGContextRef context = CGBitmapContextCreate(NULL, 67 | width, 68 | height, 69 | bitsPerComponent, 70 | bytesPerRow, 71 | colorspaceRef, 72 | kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); 73 | 74 | // Draw the image into the context and retrieve the new bitmap image without alpha 75 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 76 | CGImageRef imageRefWithoutAlpha = CGBitmapContextCreateImage(context); 77 | UIImage *imageWithoutAlpha = [UIImage imageWithCGImage:imageRefWithoutAlpha 78 | scale:image.scale 79 | orientation:image.imageOrientation]; 80 | 81 | if (unsupportedColorSpace) { 82 | CGColorSpaceRelease(colorspaceRef); 83 | } 84 | 85 | CGContextRelease(context); 86 | CGImageRelease(imageRefWithoutAlpha); 87 | 88 | return imageWithoutAlpha; 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched (successful or not) 24 | * @param totalCount The total number of images that were to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that were prefetched (whether successful or not) 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); 39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); 40 | 41 | /** 42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 43 | */ 44 | @interface SDWebImagePrefetcher : NSObject 45 | 46 | /** 47 | * The web image manager 48 | */ 49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager; 50 | 51 | /** 52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 53 | */ 54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 55 | 56 | /** 57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 58 | */ 59 | @property (nonatomic, assign) SDWebImageOptions options; 60 | 61 | /** 62 | * Queue options for Prefetcher. Defaults to Main Queue. 63 | */ 64 | @property (nonatomic, assign) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 72 | 73 | /** 74 | * Allows you to instantiate a prefetcher with any arbitrary image manager. 75 | */ 76 | - (id)initWithImageManager:(SDWebImageManager *)manager; 77 | 78 | /** 79 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 80 | * currently one image is downloaded at a time, 81 | * and skips images for failed downloads and proceed to the next image in the list 82 | * 83 | * @param urls list of URLs to prefetch 84 | */ 85 | - (void)prefetchURLs:(NSArray *)urls; 86 | 87 | /** 88 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 89 | * currently one image is downloaded at a time, 90 | * and skips images for failed downloads and proceed to the next image in the list 91 | * 92 | * @param urls list of URLs to prefetch 93 | * @param progressBlock block to be called when progress updates; 94 | * first parameter is the number of completed (successful or not) requests, 95 | * second parameter is the total number of images originally requested to be prefetched 96 | * @param completionBlock block to be called when prefetching is completed 97 | * first param is the number of completed (successful or not) requests, 98 | * second parameter is the number of skipped requests 99 | */ 100 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; 101 | 102 | /** 103 | * Remove and cancel queued list 104 | */ 105 | - (void)cancelPrefetching; 106 | 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewOtherController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewOtherController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewOtherController.h" 10 | #import "HSSetTableViewController.h" 11 | #import "UIImageView+WebCache.h" 12 | #import "SDWebImageManager.h" 13 | @interface HSSetTableViewOtherController () 14 | 15 | @property (nonatomic, strong)HSImageCellModel *cell4; ///< 16 | 17 | @end 18 | 19 | @implementation HSSetTableViewOtherController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 25 | [self initSetTableViewConfigureStyle:UITableViewStylePlain]; 26 | __weak __typeof(&*self)weakSelf = self; 27 | 28 | HSTitleCellModel *cell0 = [[HSTitleCellModel alloc] initWithTitle:@"分割线从0开始" actionBlock:^(HSBaseCellModel *model) { 29 | NSLog(@"点击事件"); 30 | }]; 31 | 32 | cell0.separateOffset = 0; 33 | cell0.separateHeight = 2; 34 | cell0.separateColor = [UIColor redColor]; 35 | 36 | 37 | 38 | HSTitleCellModel *cell1 = [[HSTitleCellModel alloc] initWithTitle:@"标题颜色和字体" actionBlock:^(HSBaseCellModel *model) { 39 | 40 | }]; 41 | cell1.titleFont = [UIFont boldSystemFontOfSize:20]; 42 | cell1.titleColor = [UIColor redColor]; 43 | 44 | //详细文本 45 | __block BOOL update = YES; 46 | 47 | HSTextCellModel *cell2 = [[HSTextCellModel alloc] initWithTitle:@"文本更新" detailText:@"加班加到口吐二两鲜血" actionBlock:^(HSBaseCellModel *model) { 48 | HSTextCellModel *detailModel = (HSTextCellModel *)model; 49 | detailModel.detailText = (update == YES?@"加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血加班加到口吐二两鲜血":@"加班加到口吐二两鲜血"); 50 | [weakSelf updateCellModel:detailModel]; 51 | update = !update; 52 | }]; 53 | cell2.arrowWidth = 30; 54 | cell2.arrowHeight = 20; 55 | cell2.arrowImage = [UIImage imageNamed:@"MoreMyBankCard"]; 56 | cell2.leftPading = 100; 57 | cell2.detailFont = [UIFont boldSystemFontOfSize:20]; 58 | cell2.detailColor = [UIColor blueColor]; 59 | 60 | 61 | 62 | 63 | 64 | HSSwitchCellModel *cell3 = [[HSSwitchCellModel alloc] initWithTitle:@"开关控制" switchType:YES switchBlock:^(HSBaseCellModel *model, BOOL on) { 65 | HSLog(@"开关控制") 66 | }]; 67 | cell3.onTintColor = [UIColor redColor]; 68 | 69 | //下载图片 70 | UIImage *placeHolder = [UIImage imageNamed:@"ic_icon_header"]; 71 | HSImageCellModel *cell4 = [[HSImageCellModel alloc] initWithTitle:@"图片" placeholderImage:placeHolder imageUrl:@"http://scimg.jb51.net/170405/2-1F40522332a13.jpg" actionBlock:^(HSBaseCellModel *model) { 72 | 73 | } imageBlock:nil]; 74 | cell4.controlRightOffset = 40; 75 | cell4.showArrow = YES; 76 | // cell4.arrowControlRightOffset = 15; 77 | self.cell4 = cell4; 78 | 79 | 80 | 81 | 82 | NSString *balance =@"88"; 83 | NSMutableAttributedString *aString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"账户: %@元",balance]]; 84 | 85 | [aString addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor]range:NSMakeRange(0,1)]; 86 | 87 | [aString addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor]range:NSMakeRange(1,1)]; 88 | 89 | [aString addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor]range:NSMakeRange(2,1)]; 90 | 91 | [aString addAttribute:NSForegroundColorAttributeName value:[UIColor purpleColor]range:NSMakeRange(3,1)]; 92 | 93 | NSString *detailbalance =@"详细内容"; 94 | NSMutableAttributedString *detailaString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"账: %@元",detailbalance]]; 95 | 96 | [detailaString addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor]range:NSMakeRange(0, 1)]; 97 | 98 | HSTextCellModel *cell6 = [[HSTextCellModel alloc] initWithAttributeTitle:aString detailAttributeText:detailaString actionBlock:nil]; 99 | cell6.leftPading = 100; 100 | 101 | 102 | 103 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:cell0,cell1,cell2, cell3,cell4,cell6,nil]; 104 | // NSMutableArray *section0 = [NSMutableArray arrayWithObjects:cell6,nil]; 105 | [self.hs_dataArry addObject:section0]; 106 | [self.hs_tableView reloadData]; 107 | } 108 | 109 | 110 | 111 | - (void)dealloc 112 | { 113 | NSLog(@"%@控制器销毁",self.class); 114 | } 115 | 116 | 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /HSSetTableViewController/View/HSImageTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSShowBigImageCell.m 3 | // HSSetTableView 4 | // 5 | // Created by hushaohui on 2017/4/21. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSImageTableViewCell.h" 10 | #import "HSImageCellModel.h" 11 | #import "UIView+HSFrame.h" 12 | #import "HSSetTableViewControllerConst.h" 13 | #import "UIImageView+WebCache.h" 14 | @interface HSImageTableViewCell() 15 | 16 | @property (nonatomic, weak)UIImageView *bigImageView; ///<右边图片显示 17 | @property (nonatomic, weak) NSLayoutConstraint *bigImageRightConstraint; ///<大图约束 18 | @property (nonatomic, weak)NSLayoutConstraint *bigImageWidthConstraint; ///<大图宽度 19 | @property (nonatomic, weak)NSLayoutConstraint *bigImageHeightConstaint; ///< 20 | @end 21 | 22 | @implementation HSImageTableViewCell 23 | 24 | + (HSBaseTableViewCell *)cellWithIdentifier:(NSString *)cellIdentifier tableView:(UITableView *)tableView; 25 | { 26 | HSImageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 27 | if(cell == nil){ 28 | cell = [[HSImageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 29 | } 30 | 31 | return cell; 32 | } 33 | 34 | - (void)setupUI 35 | { 36 | [super setupUI]; 37 | 38 | //添加默认图片 39 | UIImageView *imageView = [[UIImageView alloc] init]; 40 | imageView.frame = CGRectZero; 41 | imageView.clipsToBounds = YES; 42 | imageView.userInteractionEnabled = YES; 43 | imageView.translatesAutoresizingMaskIntoConstraints = NO; 44 | [self.contentView addSubview:imageView]; 45 | self.bigImageView = imageView; 46 | 47 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickImage:)]; 48 | [self.bigImageView addGestureRecognizer:tap]; 49 | 50 | [self setupBigImageConstraint]; 51 | } 52 | 53 | //设置大图约束 54 | - (void)setupBigImageConstraint 55 | { 56 | 57 | NSLayoutConstraint *bigImageRightConstraint = [NSLayoutConstraint constraintWithItem:self.bigImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-HS_KCellMargin]; 58 | [self.contentView addConstraint:bigImageRightConstraint]; 59 | self.bigImageRightConstraint = bigImageRightConstraint; 60 | 61 | 62 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.bigImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 63 | 64 | 65 | NSLayoutConstraint *bigImageWidthConstraint = [NSLayoutConstraint constraintWithItem:self.bigImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_KImageWidth]; 66 | [self.contentView addConstraint:bigImageWidthConstraint]; 67 | self.bigImageWidthConstraint = bigImageWidthConstraint; 68 | 69 | 70 | NSLayoutConstraint *bigImageHeightConstaint = [NSLayoutConstraint constraintWithItem:self.bigImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HS_KImageHeight]; 71 | [self.contentView addConstraint:bigImageHeightConstaint]; 72 | self.bigImageHeightConstaint = bigImageHeightConstaint; 73 | 74 | } 75 | 76 | - (void)setupDataModel:(HSBaseCellModel *)model 77 | { 78 | [super setupDataModel:model]; 79 | 80 | HSImageCellModel *bigModel = (HSImageCellModel *)model; 81 | if(!bigModel.imageIcon){ 82 | [self.bigImageView sd_setImageWithURL: [NSURL URLWithString:bigModel.imageUrl] placeholderImage:bigModel.placeHoderImage]; 83 | }else{ 84 | self.bigImageView.image = bigModel.imageIcon; 85 | } 86 | 87 | self.bigImageView.layer.cornerRadius = bigModel.cornerRadius > 0 ? bigModel.cornerRadius : 0.f; 88 | self.bigImageWidthConstraint.constant = bigModel.imageSize.width; 89 | self.bigImageHeightConstaint.constant = bigModel.imageSize.height; 90 | if(bigModel.showArrow){ 91 | self.bigImageRightConstraint.constant = - bigModel.controlRightOffset - bigModel.arrowControlRightOffset - bigModel.arrowWidth; 92 | }else{ 93 | self.bigImageRightConstraint.constant = - bigModel.controlRightOffset; 94 | } 95 | } 96 | 97 | //点击图片 98 | - (void)clickImage:(UITapGestureRecognizer *)tap 99 | { 100 | HSImageCellModel *bigModel = (HSImageCellModel *)self.cellModel; 101 | if(bigModel.imageBlock){ 102 | bigModel.imageBlock(self.cellModel); 103 | } 104 | } 105 | 106 | 107 | 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableViewQQController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewQQController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/5/8. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewQQController.h" 10 | #import "HSSetTableViewController.h" 11 | @interface HSSetTableViewQQController () 12 | 13 | @end 14 | 15 | @implementation HSSetTableViewQQController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 21 | 22 | //头像 23 | UIImage *image = [UIImage imageNamed:@"ic_icon_photo"]; 24 | HSImageCellModel *head = [[HSImageCellModel alloc] initWithTitle:@"账号管理" placeholderImage:image imageUrl:nil actionBlock:^(HSBaseCellModel *model) { 25 | 26 | } imageBlock:nil]; 27 | head.imageSize = CGSizeMake(30.0f, 30.0f); 28 | head.cornerRadius = 15; 29 | head.cellHeight = HS_KCellHeight; 30 | 31 | 32 | 33 | //手机号码 34 | NSMutableAttributedString *allString = [[NSMutableAttributedString alloc] init]; 35 | 36 | NSTextAttachment *attch = [[NSTextAttachment alloc] init]; 37 | attch.image = [UIImage imageNamed:@"ic_icon_red"]; 38 | attch.bounds = CGRectMake(0, 0, 9, 9); 39 | // 创建带有图片的富文本 40 | NSAttributedString *phoneString = [NSAttributedString attributedStringWithAttachment:attch]; 41 | [allString appendAttributedString:phoneString]; 42 | 43 | NSMutableAttributedString *numberString = [[NSMutableAttributedString alloc] initWithString:@" 186******38"]; 44 | [numberString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:[UIColor grayColor]} range:NSMakeRange(0, numberString.string.length)]; 45 | [allString appendAttributedString:numberString]; 46 | 47 | HSTextCellModel *phone = [[HSTextCellModel alloc] initWithTitle:@"手机号码" attributrDetailText:allString actionBlock:^(HSBaseCellModel *model) { 48 | 49 | }]; 50 | //QQ达人 51 | allString = [[NSMutableAttributedString alloc] init]; 52 | attch = [[NSTextAttachment alloc] init]; 53 | attch.image = [UIImage imageNamed:@"ic_icon_super"]; 54 | attch.bounds = CGRectMake(0, -2, 45, 16); 55 | // 创建带有图片的富文本 56 | phoneString = [NSAttributedString attributedStringWithAttachment:attch]; 57 | [allString appendAttributedString:phoneString]; 58 | 59 | NSMutableAttributedString *dayString = [[NSMutableAttributedString alloc] initWithString:@" 892天"]; 60 | [dayString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:[UIColor colorWithRed:221/255.0f green:187/255.0 blue:107/255.0 alpha:1.0]} range:NSMakeRange(0, dayString.string.length)]; 61 | [allString appendAttributedString:dayString]; 62 | 63 | HSTextCellModel *superMan = [[HSTextCellModel alloc] initWithTitle:@"QQ达人" attributrDetailText:allString actionBlock:^(HSBaseCellModel *model) { 64 | 65 | }]; 66 | 67 | //消息通知 68 | HSTitleCellModel *msg = [[HSTitleCellModel alloc] initWithTitle:@"消息通知" actionBlock:nil]; 69 | //聊天记录 70 | HSTitleCellModel *record = [[HSTitleCellModel alloc] initWithTitle:@"聊天记录" actionBlock:nil]; 71 | //空间清理 72 | HSTitleCellModel *clean = [[HSTitleCellModel alloc] initWithTitle:@"空间清理" actionBlock:nil]; 73 | //消息通知 74 | HSTitleCellModel *security = [[HSTitleCellModel alloc] initWithTitle:@"账号、设备安全" actionBlock:nil]; 75 | //聊天记录 76 | HSTitleCellModel *privacy = [[HSTitleCellModel alloc] initWithTitle:@"联系人、隐私" actionBlock:nil]; 77 | //空间清理 78 | HSTitleCellModel *help = [[HSTitleCellModel alloc] initWithTitle:@"辅助功能" actionBlock:nil]; 79 | //关于QQ与帮助 80 | HSTitleCellModel *about = [[HSTitleCellModel alloc] initWithTitle:@"关于QQ与帮助" actionBlock:nil]; 81 | about.showArrow = NO; 82 | about.titleColor = [UIColor redColor]; 83 | about.titileTextAlignment = NSTextAlignmentCenter; 84 | 85 | 86 | 87 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:head, phone,superMan,nil]; 88 | NSMutableArray *section1 = [NSMutableArray arrayWithObjects:msg, record,clean,nil]; 89 | NSMutableArray *section2 = [NSMutableArray arrayWithObjects:security, privacy,help,nil]; 90 | NSMutableArray *section3 = [NSMutableArray arrayWithObjects:about,nil]; 91 | [self.hs_dataArry addObject:section0]; 92 | [self.hs_dataArry addObject:section1]; 93 | [self.hs_dataArry addObject:section2]; 94 | [self.hs_dataArry addObject:section3]; 95 | [self.hs_tableView reloadData]; 96 | 97 | } 98 | 99 | - (void)dealloc 100 | { 101 | NSLog(@"%@控制器销毁",self.class); 102 | } 103 | 104 | 105 | 106 | 107 | 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /HSSetTableViewController/manager/HSSetTableViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableViewManager.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/7/24. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableViewManager.h" 10 | #import "HSBaseTableViewCell.h" 11 | #import "HSBaseCellModel.h" 12 | #import "NSArray+HSSafeAccess.h" 13 | #import "UIView+HSFrame.h" 14 | #import "HSSetTableViewControllerConst.h" 15 | #import "HSTextCellModel.h" 16 | #import "HSFooterModel.h" 17 | #import "HSHeaderModel.h" 18 | 19 | @interface HSSetTableViewManager() 20 | 21 | @property (nonatomic, strong)NSMutableArray *dataSource; ///< 22 | 23 | @end 24 | @implementation HSSetTableViewManager 25 | 26 | 27 | - (instancetype)initSetTableViewManager:(NSMutableArray *)dataSource 28 | { 29 | if(self = [super init]){ 30 | self.dataSource = dataSource; 31 | } 32 | return self; 33 | } 34 | 35 | #pragma mark - Table view data source 36 | 37 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 38 | { 39 | return self.dataSource.count; 40 | } 41 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 42 | NSMutableArray *rows = [self.dataSource hs_objectWithIndex:section]; 43 | NSAssert([rows isKindOfClass:[NSMutableArray class]], @"此对象必须为一个可变数组,请检查数据源组装方式是否正确!"); 44 | return rows.count; 45 | } 46 | 47 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 48 | { 49 | NSMutableArray *sections = [self.dataSource hs_objectWithIndex:indexPath.section]; 50 | NSAssert([sections isKindOfClass:[NSMutableArray class]], @"此对象必须为一个可变数组,请检查数据源组装方式是否正确!"); 51 | HSBaseCellModel *cellModel = (HSBaseCellModel *)[sections hs_objectWithIndex:indexPath.row]; 52 | Class class = NSClassFromString(cellModel.cellClass); 53 | NSAssert([class isSubclassOfClass:[HSBaseTableViewCell class]], @"此cellclass类别必须存在,并且继承HSBaseTableViewCell"); 54 | HSBaseTableViewCell *cell = [class cellWithIdentifier:cellModel.cellClass tableView:tableView]; 55 | [cell setupDataModel:cellModel]; 56 | cell.topLine.hidden = indexPath.row != 0; 57 | [cell.bottomLine setHs_x:(indexPath.row == sections.count - 1 ? 0:cellModel.separateOffset)]; 58 | //处理分割线 59 | return cell; 60 | } 61 | 62 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 63 | { 64 | NSMutableArray *sections = [self.dataSource hs_objectWithIndex:indexPath.section]; 65 | NSAssert([sections isKindOfClass:[NSMutableArray class]], @"此对象必须为一个可变数组,请检查数据源组装方式是否正确!"); 66 | HSBaseCellModel *cellModel = (HSBaseCellModel *)[sections hs_objectWithIndex:indexPath.row]; 67 | 68 | Class class = NSClassFromString(cellModel.cellClass); 69 | return [class getCellHeight:cellModel]; 70 | } 71 | 72 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 73 | { 74 | NSMutableArray *sections = [self.dataSource hs_objectWithIndex:indexPath.section]; 75 | NSAssert([sections isKindOfClass:[NSMutableArray class]], @"此对象必须为一个可变数组,请检查数据源组装方式是否正确!"); 76 | HSBaseCellModel *cellModel = (HSBaseCellModel *)[sections hs_objectWithIndex:indexPath.row]; 77 | [tableView deselectRowAtIndexPath:indexPath animated:cellModel.actionBlock == nil]; 78 | if(cellModel.actionBlock){ 79 | cellModel.actionBlock(cellModel); 80 | } 81 | } 82 | 83 | #pragma mark tableView代理方法 84 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 85 | { 86 | HSFooterModel *footer = (HSFooterModel*)[self.footerArry hs_objectWithIndex:section]; 87 | return footer.footerViewHeight; 88 | } 89 | 90 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 91 | { 92 | HSFooterModel *footer = (HSFooterModel*)[self.footerArry hs_objectWithIndex:section]; 93 | return footer.footerView; 94 | } 95 | 96 | 97 | -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 98 | { 99 | 100 | //如果外部不设置header给一个默认的高度 101 | if(!self.headerArry || self.headerArry.count == 0){ 102 | return HS_SectionHeight; 103 | } 104 | HSHeaderModel *header = (HSHeaderModel *)[self.headerArry hs_objectWithIndex:section]; 105 | return header.headerViewHeight; 106 | } 107 | 108 | -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 109 | { 110 | //如果外部不设置header给一个默认的透明header 111 | if(!self.headerArry || self.headerArry.count == 0){ 112 | UIView *header = [UIView new]; 113 | header.frame = CGRectMake(0, 0, HS_SCREEN_WIDTH, HS_SectionHeight); 114 | [header setBackgroundColor:[UIColor clearColor]]; 115 | return header; 116 | } 117 | HSHeaderModel *header = (HSHeaderModel *)[self.headerArry hs_objectWithIndex:section]; 118 | return header.headerView; 119 | } 120 | 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo.xcodeproj/xcuserdata/hushaohui.xcuserdatad/xcschemes/HSSetTableViewCtrollerDemo.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 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/MKAnnotationView+WebCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // MKAnnotationView+WebCache.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 14/03/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "MKAnnotationView+WebCache.h" 10 | #import "objc/runtime.h" 11 | #import "UIView+WebCacheOperation.h" 12 | 13 | static char imageURLKey; 14 | 15 | @implementation MKAnnotationView (WebCache) 16 | 17 | - (NSURL *)sd_imageURL { 18 | return objc_getAssociatedObject(self, &imageURLKey); 19 | } 20 | 21 | - (void)sd_setImageWithURL:(NSURL *)url { 22 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; 23 | } 24 | 25 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 26 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; 27 | } 28 | 29 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 30 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; 31 | } 32 | 33 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 34 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:completedBlock]; 35 | } 36 | 37 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 38 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:completedBlock]; 39 | } 40 | 41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 42 | [self sd_cancelCurrentImageLoad]; 43 | 44 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | self.image = placeholder; 46 | 47 | if (url) { 48 | __weak __typeof(self)wself = self; 49 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 50 | if (!wself) return; 51 | dispatch_main_sync_safe(^{ 52 | __strong MKAnnotationView *sself = wself; 53 | if (!sself) return; 54 | if (image) { 55 | sself.image = image; 56 | } 57 | if (completedBlock && finished) { 58 | completedBlock(image, error, cacheType, url); 59 | } 60 | }); 61 | }]; 62 | [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; 63 | } else { 64 | dispatch_main_async_safe(^{ 65 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 66 | if (completedBlock) { 67 | completedBlock(nil, error, SDImageCacheTypeNone, url); 68 | } 69 | }); 70 | } 71 | } 72 | 73 | - (void)sd_cancelCurrentImageLoad { 74 | [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; 75 | } 76 | 77 | @end 78 | 79 | 80 | @implementation MKAnnotationView (WebCacheDeprecated) 81 | 82 | - (NSURL *)imageURL { 83 | return [self sd_imageURL]; 84 | } 85 | 86 | - (void)setImageWithURL:(NSURL *)url { 87 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; 88 | } 89 | 90 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 91 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; 92 | } 93 | 94 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 95 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; 96 | } 97 | 98 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 99 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 100 | if (completedBlock) { 101 | completedBlock(image, error, cacheType); 102 | } 103 | }]; 104 | } 105 | 106 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 107 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 108 | if (completedBlock) { 109 | completedBlock(image, error, cacheType); 110 | } 111 | }]; 112 | } 113 | 114 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 115 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 116 | if (completedBlock) { 117 | completedBlock(image, error, cacheType); 118 | } 119 | }]; 120 | } 121 | 122 | - (void)cancelCurrentImageLoad { 123 | [self sd_cancelCurrentImageLoad]; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/SDWebImagePrefetcher.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImagePrefetcher.h" 10 | 11 | @interface SDWebImagePrefetcher () 12 | 13 | @property (strong, nonatomic) SDWebImageManager *manager; 14 | @property (strong, nonatomic) NSArray *prefetchURLs; 15 | @property (assign, nonatomic) NSUInteger requestedCount; 16 | @property (assign, nonatomic) NSUInteger skippedCount; 17 | @property (assign, nonatomic) NSUInteger finishedCount; 18 | @property (assign, nonatomic) NSTimeInterval startedTime; 19 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; 20 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; 21 | 22 | @end 23 | 24 | @implementation SDWebImagePrefetcher 25 | 26 | + (SDWebImagePrefetcher *)sharedImagePrefetcher { 27 | static dispatch_once_t once; 28 | static id instance; 29 | dispatch_once(&once, ^{ 30 | instance = [self new]; 31 | }); 32 | return instance; 33 | } 34 | 35 | - (id)init { 36 | return [self initWithImageManager:[SDWebImageManager new]]; 37 | } 38 | 39 | - (id)initWithImageManager:(SDWebImageManager *)manager { 40 | if ((self = [super init])) { 41 | _manager = manager; 42 | _options = SDWebImageLowPriority; 43 | _prefetcherQueue = dispatch_get_main_queue(); 44 | self.maxConcurrentDownloads = 3; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 51 | } 52 | 53 | - (NSUInteger)maxConcurrentDownloads { 54 | return self.manager.imageDownloader.maxConcurrentDownloads; 55 | } 56 | 57 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 58 | if (index >= self.prefetchURLs.count) return; 59 | self.requestedCount++; 60 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 61 | if (!finished) return; 62 | self.finishedCount++; 63 | 64 | if (image) { 65 | if (self.progressBlock) { 66 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 67 | } 68 | } 69 | else { 70 | if (self.progressBlock) { 71 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 72 | } 73 | // Add last failed 74 | self.skippedCount++; 75 | } 76 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 77 | [self.delegate imagePrefetcher:self 78 | didPrefetchURL:self.prefetchURLs[index] 79 | finishedCount:self.finishedCount 80 | totalCount:self.prefetchURLs.count 81 | ]; 82 | } 83 | if (self.prefetchURLs.count > self.requestedCount) { 84 | dispatch_async(self.prefetcherQueue, ^{ 85 | [self startPrefetchingAtIndex:self.requestedCount]; 86 | }); 87 | } else if (self.finishedCount == self.requestedCount) { 88 | [self reportStatus]; 89 | if (self.completionBlock) { 90 | self.completionBlock(self.finishedCount, self.skippedCount); 91 | self.completionBlock = nil; 92 | } 93 | self.progressBlock = nil; 94 | } 95 | }]; 96 | } 97 | 98 | - (void)reportStatus { 99 | NSUInteger total = [self.prefetchURLs count]; 100 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 101 | [self.delegate imagePrefetcher:self 102 | didFinishWithTotalCount:(total - self.skippedCount) 103 | skippedCount:self.skippedCount 104 | ]; 105 | } 106 | } 107 | 108 | - (void)prefetchURLs:(NSArray *)urls { 109 | [self prefetchURLs:urls progress:nil completed:nil]; 110 | } 111 | 112 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { 113 | [self cancelPrefetching]; // Prevent duplicate prefetch request 114 | self.startedTime = CFAbsoluteTimeGetCurrent(); 115 | self.prefetchURLs = urls; 116 | self.completionBlock = completionBlock; 117 | self.progressBlock = progressBlock; 118 | 119 | if (urls.count == 0) { 120 | if (completionBlock) { 121 | completionBlock(0,0); 122 | } 123 | } else { 124 | // Starts prefetching from the very first image on the list with the max allowed concurrency 125 | NSUInteger listCount = self.prefetchURLs.count; 126 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 127 | [self startPrefetchingAtIndex:i]; 128 | } 129 | } 130 | } 131 | 132 | - (void)cancelPrefetching { 133 | self.prefetchURLs = nil; 134 | self.skippedCount = 0; 135 | self.requestedCount = 0; 136 | self.finishedCount = 0; 137 | [self.manager cancelAll]; 138 | } 139 | 140 | @end 141 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageManager.h" 12 | 13 | /** 14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 15 | */ 16 | @interface UIImageView (HighlightedWebCache) 17 | 18 | /** 19 | * Set the imageView `highlightedImage` with an `url`. 20 | * 21 | * The download is asynchronous and cached. 22 | * 23 | * @param url The url for the image. 24 | */ 25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url; 26 | 27 | /** 28 | * Set the imageView `highlightedImage` with an `url` and custom options. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 34 | */ 35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; 36 | 37 | /** 38 | * Set the imageView `highlightedImage` with an `url`. 39 | * 40 | * The download is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param completedBlock A block called when operation has been completed. This block has no return value 44 | * and takes the requested UIImage as first parameter. In case of error the image parameter 45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 46 | * indicating if the image was retrieved from the local cache or from the network. 47 | * The fourth parameter is the original image url. 48 | */ 49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 50 | 51 | /** 52 | * Set the imageView `highlightedImage` with an `url` and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 58 | * @param completedBlock A block called when operation has been completed. This block has no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrieved from the local cache or from the network. 62 | * The fourth parameter is the original image url. 63 | */ 64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 65 | 66 | /** 67 | * Set the imageView `highlightedImage` with an `url` and custom options. 68 | * 69 | * The download is asynchronous and cached. 70 | * 71 | * @param url The url for the image. 72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 73 | * @param progressBlock A block called while image is downloading 74 | * @param completedBlock A block called when operation has been completed. This block has no return value 75 | * and takes the requested UIImage as first parameter. In case of error the image parameter 76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 77 | * indicating if the image was retrieved from the local cache or from the network. 78 | * The fourth parameter is the original image url. 79 | */ 80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 81 | 82 | /** 83 | * Cancel the current download 84 | */ 85 | - (void)sd_cancelCurrentHighlightedImageLoad; 86 | 87 | @end 88 | 89 | 90 | @interface UIImageView (HighlightedWebCacheDeprecated) 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); 93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); 94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); 97 | 98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImageView+HighlightedWebCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImageView+HighlightedWebCache.h" 10 | #import "UIView+WebCacheOperation.h" 11 | 12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" 13 | 14 | @implementation UIImageView (HighlightedWebCache) 15 | 16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url { 17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 18 | } 19 | 20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 22 | } 23 | 24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 26 | } 27 | 28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 30 | } 31 | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 33 | [self sd_cancelCurrentHighlightedImageLoad]; 34 | 35 | if (url) { 36 | __weak __typeof(self)wself = self; 37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 38 | if (!wself) return; 39 | dispatch_main_sync_safe (^ 40 | { 41 | if (!wself) return; 42 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) 43 | { 44 | completedBlock(image, error, cacheType, url); 45 | return; 46 | } 47 | else if (image) { 48 | wself.highlightedImage = image; 49 | [wself setNeedsLayout]; 50 | } 51 | if (completedBlock && finished) { 52 | completedBlock(image, error, cacheType, url); 53 | } 54 | }); 55 | }]; 56 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; 57 | } else { 58 | dispatch_main_async_safe(^{ 59 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 60 | if (completedBlock) { 61 | completedBlock(nil, error, SDImageCacheTypeNone, url); 62 | } 63 | }); 64 | } 65 | } 66 | 67 | - (void)sd_cancelCurrentHighlightedImageLoad { 68 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; 69 | } 70 | 71 | @end 72 | 73 | 74 | @implementation UIImageView (HighlightedWebCacheDeprecated) 75 | 76 | - (void)setHighlightedImageWithURL:(NSURL *)url { 77 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 78 | } 79 | 80 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 81 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 82 | } 83 | 84 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 85 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 86 | if (completedBlock) { 87 | completedBlock(image, error, cacheType); 88 | } 89 | }]; 90 | } 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 93 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 94 | if (completedBlock) { 95 | completedBlock(image, error, cacheType); 96 | } 97 | }]; 98 | } 99 | 100 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 101 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 102 | if (completedBlock) { 103 | completedBlock(image, error, cacheType); 104 | } 105 | }]; 106 | } 107 | 108 | - (void)cancelCurrentHighlightedImageLoad { 109 | [self sd_cancelCurrentHighlightedImageLoad]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.m 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+GIF.h" 10 | #import 11 | 12 | @implementation UIImage (GIF) 13 | 14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 15 | if (!data) { 16 | return nil; 17 | } 18 | 19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 20 | 21 | size_t count = CGImageSourceGetCount(source); 22 | 23 | UIImage *animatedImage; 24 | 25 | if (count <= 1) { 26 | animatedImage = [[UIImage alloc] initWithData:data]; 27 | } 28 | else { 29 | NSMutableArray *images = [NSMutableArray array]; 30 | 31 | NSTimeInterval duration = 0.0f; 32 | 33 | for (size_t i = 0; i < count; i++) { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 35 | if (!image) { 36 | continue; 37 | } 38 | 39 | duration += [self sd_frameDurationAtIndex:i source:source]; 40 | 41 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; 42 | 43 | CGImageRelease(image); 44 | } 45 | 46 | if (!duration) { 47 | duration = (1.0f / 10.0f) * count; 48 | } 49 | 50 | animatedImage = [UIImage animatedImageWithImages:images duration:duration]; 51 | } 52 | 53 | CFRelease(source); 54 | 55 | return animatedImage; 56 | } 57 | 58 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { 59 | float frameDuration = 0.1f; 60 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 61 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 62 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 63 | 64 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 65 | if (delayTimeUnclampedProp) { 66 | frameDuration = [delayTimeUnclampedProp floatValue]; 67 | } 68 | else { 69 | 70 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 71 | if (delayTimeProp) { 72 | frameDuration = [delayTimeProp floatValue]; 73 | } 74 | } 75 | 76 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 77 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 78 | // a duration of <= 10 ms. See and 79 | // for more information. 80 | 81 | if (frameDuration < 0.011f) { 82 | frameDuration = 0.100f; 83 | } 84 | 85 | CFRelease(cfFrameProperties); 86 | return frameDuration; 87 | } 88 | 89 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name { 90 | CGFloat scale = [UIScreen mainScreen].scale; 91 | 92 | if (scale > 1.0f) { 93 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; 94 | 95 | NSData *data = [NSData dataWithContentsOfFile:retinaPath]; 96 | 97 | if (data) { 98 | return [UIImage sd_animatedGIFWithData:data]; 99 | } 100 | 101 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 102 | 103 | data = [NSData dataWithContentsOfFile:path]; 104 | 105 | if (data) { 106 | return [UIImage sd_animatedGIFWithData:data]; 107 | } 108 | 109 | return [UIImage imageNamed:name]; 110 | } 111 | else { 112 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 113 | 114 | NSData *data = [NSData dataWithContentsOfFile:path]; 115 | 116 | if (data) { 117 | return [UIImage sd_animatedGIFWithData:data]; 118 | } 119 | 120 | return [UIImage imageNamed:name]; 121 | } 122 | } 123 | 124 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { 125 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { 126 | return self; 127 | } 128 | 129 | CGSize scaledSize = size; 130 | CGPoint thumbnailPoint = CGPointZero; 131 | 132 | CGFloat widthFactor = size.width / self.size.width; 133 | CGFloat heightFactor = size.height / self.size.height; 134 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; 135 | scaledSize.width = self.size.width * scaleFactor; 136 | scaledSize.height = self.size.height * scaleFactor; 137 | 138 | if (widthFactor > heightFactor) { 139 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; 140 | } 141 | else if (widthFactor < heightFactor) { 142 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; 143 | } 144 | 145 | NSMutableArray *scaledImages = [NSMutableArray array]; 146 | 147 | for (UIImage *image in self.images) { 148 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); 149 | 150 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; 151 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 152 | 153 | [scaledImages addObject:newImage]; 154 | 155 | UIGraphicsEndImageContext(); 156 | } 157 | 158 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Ctrollers/HSSetTableInfoController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HSSetTableInfoController.m 3 | // HSSetTableViewCtrollerDemo 4 | // 5 | // Created by hushaohui on 2017/4/27. 6 | // Copyright © 2017年 ZLHD. All rights reserved. 7 | // 8 | 9 | #import "HSSetTableInfoController.h" 10 | @interface HSSetTableInfoController () 11 | @property (nonatomic, strong)HSImageCellModel *header; 12 | @end       13 | 14 | @implementation HSSetTableInfoController 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | 19 | self.view.backgroundColor = [UIColor hs_colorWithHexString:@"#EBEDEF"]; 20 | self.title = @" 个人信息"; 21 | 22 | 23 | //初始化tableView 24 | [self initSetTableViewConfigureStyle:UITableViewStyleGrouped]; 25 | //模拟演示tableView frame改变 26 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 27 | [self setupTableViewConstrint:0 left:0 right:0 bottom:0]; 28 | }); 29 | [self setupTableViewConstrint:0 left:20 right:-20 bottom:0]; 30 | 31 | 32 | //组装头部和尾部视图 33 | NSMutableArray *headerModels = [NSMutableArray array]; 34 | NSMutableArray *footerModels = [NSMutableArray array]; 35 | for(NSInteger index = 0;index <= 5;index++){ 36 | UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, HS_SCREEN_WIDTH, 30)]; 37 | UILabel *lable = [[UILabel alloc] initWithFrame:header.bounds]; 38 | lable.text = [NSString stringWithFormat:@" 第%d个sectionheader",(int)index]; 39 | [header addSubview:lable]; 40 | [header setBackgroundColor:[UIColor clearColor]]; 41 | 42 | HSHeaderModel *headerModel = [HSHeaderModel new]; 43 | headerModel.headerView = header; 44 | headerModel.headerViewHeight = 30.0f; 45 | [headerModels addObject:headerModel]; 46 | 47 | UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, HS_SCREEN_WIDTH, 30)]; 48 | lable = [[UILabel alloc] initWithFrame:footer.bounds]; 49 | lable.text = [NSString stringWithFormat:@" 第%d个sectionfooter",(int)index]; 50 | [footer addSubview:lable]; 51 | [footer setBackgroundColor:[UIColor clearColor]]; 52 | 53 | HSFooterModel *footerModel = [HSFooterModel new]; 54 | footerModel.footerView = footer; 55 | footerModel.footerViewHeight = 30.0f; 56 | [footerModels addObject:footerModel]; 57 | } 58 | #if 0 59 | [self setTableViewHeaderArry:headerModels]; 60 | [self setTableViewFooterArry:footerModels]; 61 | #endif 62 | 63 | 64 | //组装数据源 65 | //头像 66 | UIImage *icon = [UIImage imageNamed:@"ic_icon_header"]; 67 | HSImageCellModel *header = [[HSImageCellModel alloc] initWithTitle:@"头像" placeholderImage:icon imageUrl:nil actionBlock:^(HSBaseCellModel *model) { 68 | 69 | } imageBlock:^(HSBaseCellModel *cellModel) { 70 | HSLog(@"点击头像--%@",cellModel) 71 | }]; 72 | self.header = header; 73 | 74 | self.header.actionBlock = ^(HSBaseCellModel *model) { 75 | // NSLog(@"self class --%@",[self class]); 76 | }; 77 | 78 | //名字 79 | HSTextCellModel *name = [[HSTextCellModel alloc] initWithTitle:@"名字" detailText:@"人名的名义" actionBlock:^(HSBaseCellModel *model) { 80 | 81 | }]; 82 | 83 | 84 | 85 | //微信号 86 | HSTextCellModel *number = [[HSTextCellModel alloc] initWithTitle:@"微信号" detailText:@"HSSetTableView" actionBlock:^(HSBaseCellModel *model) { 87 | 88 | }]; 89 | number.selectionStyle = UITableViewCellSelectionStyleNone; 90 | number.showArrow = NO; 91 | 92 | //我的二维码 93 | UIImage *image = [UIImage imageNamed:@"ic_icon_qrCode"]; 94 | HSImageCellModel *qrCode = [[HSImageCellModel alloc] initWithTitle:@"我的二维码" placeholderImage:image imageUrl:nil actionBlock:^(HSBaseCellModel *model) { 95 | 96 | } imageBlock:nil]; 97 | qrCode.imageSize = CGSizeMake(15, 15); 98 | qrCode.cellHeight = HS_KCellHeight; 99 | 100 | //我的地址 101 | HSTitleCellModel *address = [[HSTitleCellModel alloc] initWithTitle:@"我的地址" actionBlock:^(HSBaseCellModel *model) { 102 | 103 | }]; 104 | 105 | //性别 106 | HSTextCellModel *sex = [[HSTextCellModel alloc] initWithTitle:@"性别" detailText:@"男" actionBlock:nil]; 107 | 108 | //地区 109 | HSTextCellModel *area = [[HSTextCellModel alloc] initWithTitle:@"地区" detailText:@"四川 成都" actionBlock:nil]; 110 | // 111 | // 112 | //个性签名 113 | HSTextCellModel *sign = [[HSTextCellModel alloc] initWithTitle:@"签名" detailText:@"气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹气质如虹" actionBlock:nil]; 114 | // sign.controlRightOffset = 30; 115 | // sign.arrowControlRightOffset = 50; 116 | 117 | 118 | 119 | NSMutableArray *section0 = [NSMutableArray arrayWithObjects:header,name,number,qrCode,address, nil]; 120 | NSMutableArray *section1 = [NSMutableArray arrayWithObjects:area,sex,sign,nil]; 121 | 122 | [self.hs_dataArry addObject:section0]; 123 | [self.hs_dataArry addObject:section0]; 124 | [self.hs_dataArry addObject:section0]; 125 | [self.hs_dataArry addObject:section0]; 126 | [self.hs_dataArry addObject:section0]; 127 | [self.hs_dataArry addObject:section1]; 128 | 129 | 130 | 131 | } 132 | 133 | 134 | 135 | - (void)didReceiveMemoryWarning { 136 | [super didReceiveMemoryWarning]; 137 | // Dispose of any resources that can be recreated. 138 | } 139 | 140 | - (void)dealloc 141 | { 142 | NSLog(@"HSSetTableInfoController销毁"); 143 | } 144 | 145 | 146 | /* 147 | #pragma mark - Navigation 148 | 149 | // In a storyboard-based application, you will often want to do a little preparation before navigation 150 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 151 | // Get the new view controller using [segue destinationViewController]. 152 | // Pass the selected object to the new view controller. 153 | } 154 | */ 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /HSSetTableViewCtrollerDemo/HSSetTableViewCtrollerDemo/Tool/SDWebImage/MKAnnotationView+WebCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKAnnotationView+WebCache.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 14/03/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "MapKit/MapKit.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with MKAnnotationView. 14 | */ 15 | @interface MKAnnotationView (WebCache) 16 | 17 | /** 18 | * Get the current image URL. 19 | * 20 | * Note that because of the limitations of categories this property can get out of sync 21 | * if you use sd_setImage: directly. 22 | */ 23 | - (NSURL *)sd_imageURL; 24 | 25 | /** 26 | * Set the imageView `image` with an `url`. 27 | * 28 | * The download is asynchronous and cached. 29 | * 30 | * @param url The url for the image. 31 | */ 32 | - (void)sd_setImageWithURL:(NSURL *)url; 33 | 34 | /** 35 | * Set the imageView `image` with an `url` and a placeholder. 36 | * 37 | * The download is asynchronous and cached. 38 | * 39 | * @param url The url for the image. 40 | * @param placeholder The image to be set initially, until the image request finishes. 41 | * @see sd_setImageWithURL:placeholderImage:options: 42 | */ 43 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 44 | 45 | /** 46 | * Set the imageView `image` with an `url`, placeholder and custom options. 47 | * 48 | * The download is asynchronous and cached. 49 | * 50 | * @param url The url for the image. 51 | * @param placeholder The image to be set initially, until the image request finishes. 52 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 53 | */ 54 | 55 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 56 | 57 | /** 58 | * Set the imageView `image` with an `url`. 59 | * 60 | * The download is asynchronous and cached. 61 | * 62 | * @param url The url for the image. 63 | * @param completedBlock A block called when operation has been completed. This block has no return value 64 | * and takes the requested UIImage as first parameter. In case of error the image parameter 65 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 66 | * indicating if the image was retrieved from the local cache or from the network. 67 | * The fourth parameter is the original image url. 68 | */ 69 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 70 | 71 | /** 72 | * Set the imageView `image` with an `url`, placeholder. 73 | * 74 | * The download is asynchronous and cached. 75 | * 76 | * @param url The url for the image. 77 | * @param placeholder The image to be set initially, until the image request finishes. 78 | * @param completedBlock A block called when operation has been completed. This block has no return value 79 | * and takes the requested UIImage as first parameter. In case of error the image parameter 80 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 81 | * indicating if the image was retrieved from the local cache or from the network. 82 | * The fourth parameter is the original image url. 83 | */ 84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 85 | 86 | /** 87 | * Set the imageView `image` with an `url`, placeholder and custom options. 88 | * 89 | * The download is asynchronous and cached. 90 | * 91 | * @param url The url for the image. 92 | * @param placeholder The image to be set initially, until the image request finishes. 93 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 94 | * @param completedBlock A block called when operation has been completed. This block has no return value 95 | * and takes the requested UIImage as first parameter. In case of error the image parameter 96 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 97 | * indicating if the image was retrieved from the local cache or from the network. 98 | * The fourth parameter is the original image url. 99 | */ 100 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 101 | 102 | /** 103 | * Cancel the current download 104 | */ 105 | - (void)sd_cancelCurrentImageLoad; 106 | 107 | @end 108 | 109 | 110 | @interface MKAnnotationView (WebCacheDeprecated) 111 | 112 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); 113 | 114 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); 115 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); 116 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`"); 117 | 118 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); 119 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); 120 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); 121 | 122 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); 123 | 124 | @end 125 | --------------------------------------------------------------------------------