├── .swift-version ├── ChannelEditDemo ├── .DS_Store ├── Assets.xcassets │ ├── Contents.json │ ├── .DS_Store │ └── AppIcon.appiconset │ │ └── Contents.json ├── LRLChannelEdit │ ├── .DS_Store │ ├── LRLChannelEdit.bundle │ │ ├── del.png │ │ ├── close.png │ │ ├── finsh.png │ │ ├── lanmu.png │ │ ├── close-1.png │ │ ├── close@2x.png │ │ ├── close@3x.png │ │ ├── del@2x.png │ │ ├── del@3x.png │ │ ├── finsh-1.png │ │ ├── finsh@2x.png │ │ ├── finsh@3x.png │ │ ├── lanmu2.png │ │ ├── lanmu@2x.png │ │ ├── lanmu@3x.png │ │ ├── reorder.png │ │ ├── close-1@2x.png │ │ ├── close-1@3x.png │ │ ├── finsh-1@2x.png │ │ ├── finsh-1@3x.png │ │ ├── lanmu2@2x.png │ │ ├── lanmu2@3x.png │ │ ├── reorder-1.png │ │ ├── reorder@2x.png │ │ ├── reorder@3x.png │ │ ├── reorder-1@2x.png │ │ └── reorder-1@3x.png │ ├── UIImage+LRLBundle.h │ ├── LRLChannelUnitModel.h │ ├── LRLTouchView.h │ ├── UIImage+LRLBundle.m │ ├── LRLChannelUnitModel.m │ ├── LRLChannelEditController.h │ ├── LRLTouchView.m │ ├── LRLChannelEditController.xib │ └── LRLChannelEditController.m ├── ViewController.h ├── AppDelegate.h ├── main.m ├── AppDelegate.m ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard └── ViewController.m ├── Screenshots └── Screenshot1.png ├── ChannelEditDemo.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── liuruilong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcuserdata │ └── liuruilong.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── ChannelEditDemo.xcscheme └── project.pbxproj ├── README.md ├── .travis.yml ├── LICENSE ├── .gitignore └── LRLChannelEditController.podspec /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /ChannelEditDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/.DS_Store -------------------------------------------------------------------------------- /Screenshots/Screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/Screenshots/Screenshot1.png -------------------------------------------------------------------------------- /ChannelEditDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/.DS_Store -------------------------------------------------------------------------------- /ChannelEditDemo/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/del@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/close-1@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/finsh-1@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/lanmu2@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1@2x.png -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo/LRLChannelEdit/LRLChannelEdit.bundle/reorder-1@3x.png -------------------------------------------------------------------------------- /ChannelEditDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ChannelEditDemo.xcodeproj/project.xcworkspace/xcuserdata/liuruilong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayLiu2015/channelEdit/HEAD/ChannelEditDemo.xcodeproj/project.xcworkspace/xcuserdata/liuruilong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ChannelEditDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 16/1/5. 6 | // Copyright © 2016年 liuRuiLong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/UIImage+LRLBundle.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+LRLBundle.h 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 2017/5/21. 6 | // Copyright © 2017年 liuRuiLong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (LRLBundle) 12 | +(UIImage *)imageMyBundleNamed:(NSString *)imageName; 13 | @end 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/codeWorm2015/channelEdit.svg?branch=master)](https://travis-ci.org/codeWorm2015/channelEdit) 2 | 3 | 4 | 5 | **CocoaPods** 6 | 7 | ` 8 | pod 'LRLChannelEditController', '~> 1.0.4' 9 | ` 10 | 11 | -------------------------------------------------------------------------------- /ChannelEditDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 16/1/5. 6 | // Copyright © 2016年 liuRuiLong. 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 | -------------------------------------------------------------------------------- /ChannelEditDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 16/1/5. 6 | // Copyright © 2016年 liuRuiLong. 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 | -------------------------------------------------------------------------------- /ChannelEditDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 16/1/5. 6 | // Copyright © 2016年 liuRuiLong. 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 | return YES; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelUnitModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChannelUnitModel.h 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/10. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LRLChannelUnitModel : NSObject 12 | 13 | @property (nonatomic, copy) NSString *cid; 14 | 15 | @property (nonatomic, copy) NSString *name; 16 | 17 | @property (nonatomic, assign) BOOL isTop; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLTouchView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TouchView.h 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/2. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LRLTouchView : UIView 12 | 13 | @property (nonatomic, strong) UILabel *contentLabel; 14 | @property (nonatomic, strong) UIImageView *closeImageView; 15 | @property (nonatomic, strong) UIPanGestureRecognizer *pan; 16 | @property (nonatomic, strong) UITapGestureRecognizer *tap; 17 | @property (nonatomic, strong) UILongPressGestureRecognizer *longPress; 18 | 19 | -(void)inOrOutTouching:(BOOL)inOrOut; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ChannelEditDemo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ChannelEditDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FC83F4021C3BFA8700EC8003 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | os: osx 3 | osx_image: xcode8.3 4 | 5 | env: 6 | matrix: 7 | - TEST_TYPE=iOS 8 | -before_install: 9 | - | 10 | gem install xcpretty -N --no-ri --no-rdoc 11 | script: 12 | # - | 13 | # ./setup.sh 14 | # if [ "$TEST_TYPE" = iOS ]; then 15 | # set -o pipefail 16 | # xcodebuild clean test -workspace Kingfisher.xcworkspace -scheme Kingfisher -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' -enableCodeCoverage YES | xcpretty 17 | # fi 18 | after_success: 19 | - sleep 5 20 | - if [ "$TEST_TYPE" = iOS ]; then 21 | bash <(curl -s https://codecov.io/bash) 22 | fi 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/UIImage+LRLBundle.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+LRLBundle.m 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 2017/5/21. 6 | // Copyright © 2017年 liuRuiLong. All rights reserved. 7 | // 8 | 9 | #import "UIImage+LRLBundle.h" 10 | 11 | @implementation UIImage(MyBundle) 12 | 13 | +(UIImage *)imageMyBundleNamed:(NSString *)imageName{ 14 | UIImage *image = [UIImage imageNamed:[@"LRLChannelEdit.bundle" stringByAppendingPathComponent:imageName]]; 15 | if (image) { 16 | return image; 17 | } else { 18 | image = [UIImage imageNamed:[@"Frameworks/LRLChannelEdit.framework/LRLChannelEdit.bundle" stringByAppendingPathComponent:imageName]]; 19 | if (!image) { 20 | image = [UIImage imageNamed:imageName]; 21 | } 22 | return image; 23 | } 24 | } 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelUnitModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChannelUnitModel.m 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/10. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LRLChannelUnitModel.h" 11 | 12 | @implementation LRLChannelUnitModel 13 | -(NSString *)description{ 14 | unsigned int count = 0; 15 | Ivar *ivars = class_copyIvarList(self.class, &count); 16 | NSMutableString *str = [NSMutableString string]; 17 | for (int i = 0; i < count; ++i) { 18 | Ivar ivar = ivars[i]; 19 | const char *name = ivar_getName(ivar); 20 | NSString *proName = [NSString stringWithUTF8String:name]; 21 | id value = [self valueForKey:proName]; 22 | 23 | [str appendFormat:@"<%@ : %@> \n", proName, value]; 24 | } 25 | free(ivars); 26 | return str; 27 | } 28 | @end 29 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEditController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LRLChannelEditController.h 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/2. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import "LRLChannelUnitModel.h" 10 | 11 | #import 12 | 13 | @interface LRLChannelEditController : UIViewController 14 | 15 | -(id)initWithTopDataSource:(NSArray *)topDataArr andBottomDataSource:(NSArray *)bottomDataSource andInitialIndex:(NSInteger)initialIndex; 16 | 17 | /** 18 | @b 固定按钮的数量, 默认为0, 必须小于 topDataArr 的数量 19 | */ 20 | @property (assign, nonatomic) NSUInteger fixedCount; 21 | 22 | /** 23 | * @b 编辑后, 删除初始选中项排序的回调 24 | */ 25 | @property (nonatomic, copy) void(^removeInitialIndexBlock)(NSMutableArray *topArr, NSMutableArray *bottomArr); 26 | 27 | /** 28 | * @b 选中某一个频道回调 29 | */ 30 | @property (nonatomic, copy) void(^chooseIndexBlock)(NSInteger index, NSMutableArray *topArr, NSMutableArray *bottomArr); 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2016 Liu Ruilong 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /ChannelEditDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | *.DS_Store 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | # CocoaPods 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # 38 | # Pods/ 39 | 40 | # Carthage 41 | # 42 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 43 | # Carthage/Checkouts 44 | 45 | Carthage/Build 46 | 47 | # fastlane 48 | # 49 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 50 | # screenshots whenever they are needed. 51 | # For more information about the recommended setup visit: 52 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 53 | 54 | fastlane/report.xml 55 | fastlane/Preview.html 56 | fastlane/screenshots 57 | fastlane/test_output 58 | 59 | # Code Injection 60 | # 61 | # After new code Injection tools there's a generated folder /iOSInjectionProject 62 | # https://github.com/johnno1962/injectionforxcode 63 | 64 | iOSInjectionProject/ 65 | -------------------------------------------------------------------------------- /ChannelEditDemo/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 | -------------------------------------------------------------------------------- /ChannelEditDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLTouchView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TouchView.m 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/2. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import "LRLTouchView.h" 10 | #import "UIImage+LRLBundle.h" 11 | 12 | @implementation LRLTouchView 13 | 14 | -(float)getTextSizeWithInOrOut:(BOOL)inOrOut{ 15 | if (inOrOut) { 16 | return 15.0; 17 | }else{ 18 | return 12.0; 19 | } 20 | } 21 | 22 | -(instancetype)initWithFrame:(CGRect)frame{ 23 | if (self = [super initWithFrame:frame]) { 24 | self.backgroundColor = [UIColor clearColor]; 25 | self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, self.bounds.size.width - 10, self.bounds.size.height - 10)]; 26 | self.contentLabel.textAlignment = NSTextAlignmentCenter; 27 | self.contentLabel.backgroundColor = [UIColor colorWithRed:236.0/255.0 green:236.0/255.0 blue:236.0/255.0 alpha:1.0]; 28 | 29 | self.contentLabel.font = [UIFont systemFontOfSize:[self getTextSizeWithInOrOut:NO]]; 30 | self.contentLabel.textColor = [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0]; 31 | [self addSubview:self.contentLabel]; 32 | 33 | self.closeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width - 16.5, 1.5, 15, 15)]; 34 | self.closeImageView.hidden = YES; 35 | self.closeImageView.image = [UIImage imageMyBundleNamed:@"del"]; 36 | [self addSubview:self.closeImageView]; 37 | } 38 | return self; 39 | } 40 | 41 | -(void)inOrOutTouching:(BOOL)inOrOut{ 42 | if (inOrOut) { 43 | self.contentLabel.frame = self.bounds; 44 | self.contentLabel.font = [UIFont systemFontOfSize:[self getTextSizeWithInOrOut:YES]]; 45 | self.backgroundColor = self.contentLabel.backgroundColor; 46 | self.alpha = 0.7; 47 | self.contentLabel.alpha = 0.7; 48 | }else{ 49 | self.contentLabel.frame = CGRectMake(5, 5, self.bounds.size.width - 10, self.bounds.size.height - 10); 50 | self.contentLabel.font = [UIFont systemFontOfSize:[self getTextSizeWithInOrOut:NO]]; 51 | self.backgroundColor = [UIColor clearColor]; 52 | self.alpha = 1.0; 53 | self.contentLabel.alpha = 1.0; 54 | } 55 | } 56 | @end 57 | -------------------------------------------------------------------------------- /ChannelEditDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ChannelEditDemo 4 | // 5 | // Created by liuRuiLong on 16/1/5. 6 | // Copyright © 2016年 liuRuiLong. All rights reserved. 7 | // 8 | 9 | #import "LRLChannelEditController.h" 10 | #import "ViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) NSMutableArray *topChannelArr; 15 | 16 | @property (nonatomic, strong) NSMutableArray *bottomChannelArr; 17 | 18 | @property (nonatomic, assign) NSInteger chooseIndex; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | } 27 | 28 | -(NSMutableArray *)topChannelArr{ 29 | if (!_topChannelArr) { 30 | //这里模拟从本地获取的频道数组 31 | _topChannelArr = [NSMutableArray array]; 32 | for (int i = 0; i < 50; ++i) { 33 | LRLChannelUnitModel *channelModel = [[LRLChannelUnitModel alloc] init]; 34 | channelModel.name = [NSString stringWithFormat:@"标题%d", i]; 35 | channelModel.cid = [NSString stringWithFormat:@"%d", i]; 36 | channelModel.isTop = YES; 37 | [_topChannelArr addObject:channelModel]; 38 | } 39 | } 40 | return _topChannelArr; 41 | } 42 | -(NSMutableArray *)bottomChannelArr{ 43 | if (!_bottomChannelArr) { 44 | _bottomChannelArr = [NSMutableArray array]; 45 | for (int i = 30; i < 50; ++i) { 46 | LRLChannelUnitModel *channelModel = [[LRLChannelUnitModel alloc] init]; 47 | channelModel.name = [NSString stringWithFormat:@"标题%d", i]; 48 | channelModel.cid = [NSString stringWithFormat:@"%d", i]; 49 | channelModel.isTop = NO; 50 | [_bottomChannelArr addObject:channelModel]; 51 | } 52 | 53 | } 54 | return _bottomChannelArr; 55 | } 56 | 57 | #pragma mark - 跳转都频道编辑页面 58 | - (IBAction)goToTheChannelEdit:(id)sender { 59 | LRLChannelEditController *channelEdit = [[LRLChannelEditController alloc] initWithTopDataSource:self.topChannelArr andBottomDataSource:self.bottomChannelArr andInitialIndex:self.chooseIndex]; 60 | 61 | //编辑后的回调 62 | __weak ViewController *weakSelf = self; 63 | channelEdit.removeInitialIndexBlock = ^(NSMutableArray *topArr, NSMutableArray *bottomArr){ 64 | weakSelf.topChannelArr = topArr; 65 | weakSelf.bottomChannelArr = bottomArr; 66 | NSLog(@"删除了初始选中项的回调:\n保留的频道有: %@", topArr); 67 | }; 68 | channelEdit.chooseIndexBlock = ^(NSInteger index, NSMutableArray *topArr, NSMutableArray *bottomArr){ 69 | weakSelf.topChannelArr = topArr; 70 | weakSelf.bottomChannelArr = bottomArr; 71 | weakSelf.chooseIndex = index; 72 | NSLog(@"选中了某一项的回调:\n保留的频道有: %@, 选中第%ld个频道", topArr, index); 73 | }; 74 | 75 | channelEdit.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 76 | [self presentViewController:channelEdit animated:YES completion:nil]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /ChannelEditDemo/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 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /ChannelEditDemo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/ChannelEditDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /LRLChannelEditController.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint ChannelEdit.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "LRLChannelEditController" 19 | s.version = "1.0.4" 20 | s.summary = "模仿今日头条, 网易频道编辑" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | #s.description = <<-DESC 28 | # DESC 29 | 30 | s.homepage = "https://github.com/codeWorm2015/channelEdit.git" 31 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 32 | 33 | 34 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 35 | # 36 | # Licensing your code is important. See http://choosealicense.com for more info. 37 | # CocoaPods will detect a license file if there is a named LICENSE* 38 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 39 | # 40 | 41 | #s.license = "MIT" 42 | s.license = { :type => "MIT", :file => "/Users/liuruilong/Desktop/codeWorm_git/channelEdit/LICENSE" } 43 | 44 | 45 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 46 | # 47 | # Specify the authors of the library, with email addresses. Email addresses 48 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 49 | # accepts just a name if you'd rather not provide an email address. 50 | # 51 | # Specify a social_media_url where others can refer to, for example a twitter 52 | # profile URL. 53 | # 54 | 55 | s.author = { "codeWorm" => "liu_rui_long@163.com" } 56 | # Or just: s.author = "codeWorm" 57 | # s.authors = { "codeWorm" => "liu_rui_long@163.com" } 58 | # s.social_media_url = "http://twitter.com/codeWorm" 59 | 60 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 61 | # 62 | # If this Pod runs only on iOS or OS X, then specify the platform and 63 | # the deployment target. You can optionally include the target after the platform. 64 | # 65 | 66 | # s.platform = :ios 67 | s.platform = :ios, "7.0" 68 | 69 | # When using multiple platforms 70 | # s.ios.deployment_target = "5.0" 71 | # s.osx.deployment_target = "10.7" 72 | # s.watchos.deployment_target = "2.0" 73 | # s.tvos.deployment_target = "9.0" 74 | 75 | 76 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 77 | # 78 | # Specify the location from where the source should be retrieved. 79 | # Supports git, hg, bzr, svn and HTTP. 80 | # 81 | 82 | s.source = { :git => "https://github.com/codeWorm2015/channelEdit.git", :tag => "1.0.4" } 83 | 84 | 85 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 86 | # 87 | # CocoaPods is smart about how it includes source code. For source files 88 | # giving a folder will include any swift, h, m, mm, c & cpp files. 89 | # For header files it will include any header in the folder. 90 | # Not including the public_header_files will make all headers public. 91 | # 92 | 93 | s.source_files = "ChannelEditDemo/LRLChannelEdit/**/*.{h,m}" 94 | #s.exclude_files = "Classes/Exclude" 95 | 96 | s.public_header_files = "ChannelEditDemo/LRLChannelEdit/**/LRLChannelEditController.h","ChannelEditDemo/LRLChannelEdit/**/LRLChannelUnitModel.h" 97 | 98 | 99 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 100 | # 101 | # A list of resources included with the Pod. These are copied into the 102 | # target bundle with a build phase script. Anything else will be cleaned. 103 | # You can preserve files from being cleaned, please don't preserve 104 | # non-essential files like tests, examples and documentation. 105 | # 106 | 107 | # s.resource = "icon.png" 108 | # s.resources = "Resources/*.png" 109 | s.resources = "ChannelEditDemo/LRLChannelEdit/*.{png,xib,nib,bundle}" 110 | 111 | 112 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 113 | 114 | 115 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 116 | # 117 | # Link your library with frameworks, or libraries. Libraries do not include 118 | # the lib prefix of their name. 119 | # 120 | 121 | # s.framework = "SomeFramework" 122 | # s.frameworks = "SomeFramework", "AnotherFramework" 123 | 124 | # s.library = "iconv" 125 | # s.libraries = "iconv", "xml2" 126 | 127 | 128 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 129 | # 130 | # If your library depends on compiler flags you can set them in the xcconfig hash 131 | # where they will only apply to your library. If you depend on other Podspecs 132 | # you can include multiple dependencies to ensure it works. 133 | 134 | # s.requires_arc = true 135 | 136 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 137 | # s.dependency "JSONKit", "~> 1.4" 138 | 139 | `echo "3.0" > .swift-version` 140 | 141 | end 142 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEditController.xib: -------------------------------------------------------------------------------- 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 | 50 | 51 | 52 | 53 | 63 | 73 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /ChannelEditDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FC83F4081C3BFA8700EC8003 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F4071C3BFA8700EC8003 /* main.m */; }; 11 | FC83F40B1C3BFA8700EC8003 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F40A1C3BFA8700EC8003 /* AppDelegate.m */; }; 12 | FC83F40E1C3BFA8700EC8003 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F40D1C3BFA8700EC8003 /* ViewController.m */; }; 13 | FC83F4111C3BFA8700EC8003 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC83F40F1C3BFA8700EC8003 /* Main.storyboard */; }; 14 | FC83F4131C3BFA8700EC8003 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC83F4121C3BFA8700EC8003 /* Assets.xcassets */; }; 15 | FC83F4161C3BFA8700EC8003 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC83F4141C3BFA8700EC8003 /* LaunchScreen.storyboard */; }; 16 | FC83F4211C3BFAAC00EC8003 /* LRLChannelEditController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F41F1C3BFAAC00EC8003 /* LRLChannelEditController.m */; }; 17 | FC83F4221C3BFAAC00EC8003 /* LRLChannelEditController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FC83F4201C3BFAAC00EC8003 /* LRLChannelEditController.xib */; }; 18 | FC83F4251C3BFBB600EC8003 /* LRLChannelUnitModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F4241C3BFBB600EC8003 /* LRLChannelUnitModel.m */; }; 19 | FC83F4281C3BFC1C00EC8003 /* LRLTouchView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC83F4271C3BFC1C00EC8003 /* LRLTouchView.m */; }; 20 | FCE5989D1ED160D300E4BE39 /* LRLChannelEdit.bundle in Resources */ = {isa = PBXBuildFile; fileRef = FCE5989C1ED160D300E4BE39 /* LRLChannelEdit.bundle */; }; 21 | FCE598A01ED167E900E4BE39 /* UIImage+LRLBundle.m in Sources */ = {isa = PBXBuildFile; fileRef = FCE5989F1ED167E900E4BE39 /* UIImage+LRLBundle.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | FC83F4031C3BFA8700EC8003 /* ChannelEditDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChannelEditDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | FC83F4071C3BFA8700EC8003 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 27 | FC83F4091C3BFA8700EC8003 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 28 | FC83F40A1C3BFA8700EC8003 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 29 | FC83F40C1C3BFA8700EC8003 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 30 | FC83F40D1C3BFA8700EC8003 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 31 | FC83F4101C3BFA8700EC8003 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 32 | FC83F4121C3BFA8700EC8003 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 33 | FC83F4151C3BFA8700EC8003 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 34 | FC83F4171C3BFA8700EC8003 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | FC83F41E1C3BFAAC00EC8003 /* LRLChannelEditController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRLChannelEditController.h; sourceTree = ""; }; 36 | FC83F41F1C3BFAAC00EC8003 /* LRLChannelEditController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRLChannelEditController.m; sourceTree = ""; }; 37 | FC83F4201C3BFAAC00EC8003 /* LRLChannelEditController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LRLChannelEditController.xib; sourceTree = ""; }; 38 | FC83F4231C3BFBB600EC8003 /* LRLChannelUnitModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRLChannelUnitModel.h; sourceTree = ""; }; 39 | FC83F4241C3BFBB600EC8003 /* LRLChannelUnitModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRLChannelUnitModel.m; sourceTree = ""; }; 40 | FC83F4261C3BFC1C00EC8003 /* LRLTouchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRLTouchView.h; sourceTree = ""; }; 41 | FC83F4271C3BFC1C00EC8003 /* LRLTouchView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRLTouchView.m; sourceTree = ""; }; 42 | FCE5989C1ED160D300E4BE39 /* LRLChannelEdit.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = LRLChannelEdit.bundle; sourceTree = ""; }; 43 | FCE5989E1ED167E900E4BE39 /* UIImage+LRLBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+LRLBundle.h"; sourceTree = ""; }; 44 | FCE5989F1ED167E900E4BE39 /* UIImage+LRLBundle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+LRLBundle.m"; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | FC83F4001C3BFA8700EC8003 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | FC83F3FA1C3BFA8600EC8003 = { 59 | isa = PBXGroup; 60 | children = ( 61 | FC83F4051C3BFA8700EC8003 /* ChannelEditDemo */, 62 | FC83F4041C3BFA8700EC8003 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | FC83F4041C3BFA8700EC8003 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | FC83F4031C3BFA8700EC8003 /* ChannelEditDemo.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | FC83F4051C3BFA8700EC8003 /* ChannelEditDemo */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | FC83F4091C3BFA8700EC8003 /* AppDelegate.h */, 78 | FC83F40A1C3BFA8700EC8003 /* AppDelegate.m */, 79 | FC83F41D1C3BFAAC00EC8003 /* LRLChannelEdit */, 80 | FC83F40C1C3BFA8700EC8003 /* ViewController.h */, 81 | FC83F40D1C3BFA8700EC8003 /* ViewController.m */, 82 | FC83F40F1C3BFA8700EC8003 /* Main.storyboard */, 83 | FC83F4121C3BFA8700EC8003 /* Assets.xcassets */, 84 | FC83F4141C3BFA8700EC8003 /* LaunchScreen.storyboard */, 85 | FC83F4171C3BFA8700EC8003 /* Info.plist */, 86 | FC83F4061C3BFA8700EC8003 /* Supporting Files */, 87 | ); 88 | path = ChannelEditDemo; 89 | sourceTree = ""; 90 | }; 91 | FC83F4061C3BFA8700EC8003 /* Supporting Files */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | FC83F4071C3BFA8700EC8003 /* main.m */, 95 | ); 96 | name = "Supporting Files"; 97 | sourceTree = ""; 98 | }; 99 | FC83F41D1C3BFAAC00EC8003 /* LRLChannelEdit */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | FCE5989C1ED160D300E4BE39 /* LRLChannelEdit.bundle */, 103 | FC83F4231C3BFBB600EC8003 /* LRLChannelUnitModel.h */, 104 | FC83F4241C3BFBB600EC8003 /* LRLChannelUnitModel.m */, 105 | FC83F4261C3BFC1C00EC8003 /* LRLTouchView.h */, 106 | FC83F4271C3BFC1C00EC8003 /* LRLTouchView.m */, 107 | FC83F41E1C3BFAAC00EC8003 /* LRLChannelEditController.h */, 108 | FC83F41F1C3BFAAC00EC8003 /* LRLChannelEditController.m */, 109 | FC83F4201C3BFAAC00EC8003 /* LRLChannelEditController.xib */, 110 | FCE5989E1ED167E900E4BE39 /* UIImage+LRLBundle.h */, 111 | FCE5989F1ED167E900E4BE39 /* UIImage+LRLBundle.m */, 112 | ); 113 | path = LRLChannelEdit; 114 | sourceTree = ""; 115 | }; 116 | /* End PBXGroup section */ 117 | 118 | /* Begin PBXNativeTarget section */ 119 | FC83F4021C3BFA8700EC8003 /* ChannelEditDemo */ = { 120 | isa = PBXNativeTarget; 121 | buildConfigurationList = FC83F41A1C3BFA8700EC8003 /* Build configuration list for PBXNativeTarget "ChannelEditDemo" */; 122 | buildPhases = ( 123 | FC83F3FF1C3BFA8700EC8003 /* Sources */, 124 | FC83F4001C3BFA8700EC8003 /* Frameworks */, 125 | FC83F4011C3BFA8700EC8003 /* Resources */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = ChannelEditDemo; 132 | productName = ChannelEditDemo; 133 | productReference = FC83F4031C3BFA8700EC8003 /* ChannelEditDemo.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | /* End PBXNativeTarget section */ 137 | 138 | /* Begin PBXProject section */ 139 | FC83F3FB1C3BFA8600EC8003 /* Project object */ = { 140 | isa = PBXProject; 141 | attributes = { 142 | LastUpgradeCheck = 0720; 143 | ORGANIZATIONNAME = liuRuiLong; 144 | TargetAttributes = { 145 | FC83F4021C3BFA8700EC8003 = { 146 | CreatedOnToolsVersion = 7.2; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = FC83F3FE1C3BFA8600EC8003 /* Build configuration list for PBXProject "ChannelEditDemo" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = FC83F3FA1C3BFA8600EC8003; 159 | productRefGroup = FC83F4041C3BFA8700EC8003 /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | FC83F4021C3BFA8700EC8003 /* ChannelEditDemo */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | FC83F4011C3BFA8700EC8003 /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | FC83F4161C3BFA8700EC8003 /* LaunchScreen.storyboard in Resources */, 174 | FC83F4131C3BFA8700EC8003 /* Assets.xcassets in Resources */, 175 | FCE5989D1ED160D300E4BE39 /* LRLChannelEdit.bundle in Resources */, 176 | FC83F4221C3BFAAC00EC8003 /* LRLChannelEditController.xib in Resources */, 177 | FC83F4111C3BFA8700EC8003 /* Main.storyboard in Resources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXResourcesBuildPhase section */ 182 | 183 | /* Begin PBXSourcesBuildPhase section */ 184 | FC83F3FF1C3BFA8700EC8003 /* Sources */ = { 185 | isa = PBXSourcesBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | FCE598A01ED167E900E4BE39 /* UIImage+LRLBundle.m in Sources */, 189 | FC83F4281C3BFC1C00EC8003 /* LRLTouchView.m in Sources */, 190 | FC83F40E1C3BFA8700EC8003 /* ViewController.m in Sources */, 191 | FC83F40B1C3BFA8700EC8003 /* AppDelegate.m in Sources */, 192 | FC83F4211C3BFAAC00EC8003 /* LRLChannelEditController.m in Sources */, 193 | FC83F4081C3BFA8700EC8003 /* main.m in Sources */, 194 | FC83F4251C3BFBB600EC8003 /* LRLChannelUnitModel.m in Sources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXSourcesBuildPhase section */ 199 | 200 | /* Begin PBXVariantGroup section */ 201 | FC83F40F1C3BFA8700EC8003 /* Main.storyboard */ = { 202 | isa = PBXVariantGroup; 203 | children = ( 204 | FC83F4101C3BFA8700EC8003 /* Base */, 205 | ); 206 | name = Main.storyboard; 207 | sourceTree = ""; 208 | }; 209 | FC83F4141C3BFA8700EC8003 /* LaunchScreen.storyboard */ = { 210 | isa = PBXVariantGroup; 211 | children = ( 212 | FC83F4151C3BFA8700EC8003 /* Base */, 213 | ); 214 | name = LaunchScreen.storyboard; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXVariantGroup section */ 218 | 219 | /* Begin XCBuildConfiguration section */ 220 | FC83F4181C3BFA8700EC8003 /* Debug */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ALWAYS_SEARCH_USER_PATHS = NO; 224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 225 | CLANG_CXX_LIBRARY = "libc++"; 226 | CLANG_ENABLE_MODULES = YES; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_WARN_BOOL_CONVERSION = YES; 229 | CLANG_WARN_CONSTANT_CONVERSION = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INT_CONVERSION = YES; 234 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 235 | CLANG_WARN_UNREACHABLE_CODE = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | COPY_PHASE_STRIP = NO; 239 | DEBUG_INFORMATION_FORMAT = dwarf; 240 | ENABLE_STRICT_OBJC_MSGSEND = YES; 241 | ENABLE_TESTABILITY = YES; 242 | GCC_C_LANGUAGE_STANDARD = gnu99; 243 | GCC_DYNAMIC_NO_PIC = NO; 244 | GCC_NO_COMMON_BLOCKS = YES; 245 | GCC_OPTIMIZATION_LEVEL = 0; 246 | GCC_PREPROCESSOR_DEFINITIONS = ( 247 | "DEBUG=1", 248 | "$(inherited)", 249 | ); 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 257 | MTL_ENABLE_DEBUG_INFO = YES; 258 | ONLY_ACTIVE_ARCH = YES; 259 | SDKROOT = iphoneos; 260 | TARGETED_DEVICE_FAMILY = "1,2"; 261 | }; 262 | name = Debug; 263 | }; 264 | FC83F4191C3BFA8700EC8003 /* Release */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 269 | CLANG_CXX_LIBRARY = "libc++"; 270 | CLANG_ENABLE_MODULES = YES; 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | CLANG_WARN_BOOL_CONVERSION = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INT_CONVERSION = YES; 278 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 284 | ENABLE_NS_ASSERTIONS = NO; 285 | ENABLE_STRICT_OBJC_MSGSEND = YES; 286 | GCC_C_LANGUAGE_STANDARD = gnu99; 287 | GCC_NO_COMMON_BLOCKS = YES; 288 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 289 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 290 | GCC_WARN_UNDECLARED_SELECTOR = YES; 291 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 292 | GCC_WARN_UNUSED_FUNCTION = YES; 293 | GCC_WARN_UNUSED_VARIABLE = YES; 294 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 295 | MTL_ENABLE_DEBUG_INFO = NO; 296 | SDKROOT = iphoneos; 297 | TARGETED_DEVICE_FAMILY = "1,2"; 298 | VALIDATE_PRODUCT = YES; 299 | }; 300 | name = Release; 301 | }; 302 | FC83F41B1C3BFA8700EC8003 /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | INFOPLIST_FILE = ChannelEditDemo/Info.plist; 307 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | PRODUCT_BUNDLE_IDENTIFIER = "---.ChannelEditDemo"; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | }; 312 | name = Debug; 313 | }; 314 | FC83F41C1C3BFA8700EC8003 /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 318 | INFOPLIST_FILE = ChannelEditDemo/Info.plist; 319 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 320 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 321 | PRODUCT_BUNDLE_IDENTIFIER = "---.ChannelEditDemo"; 322 | PRODUCT_NAME = "$(TARGET_NAME)"; 323 | }; 324 | name = Release; 325 | }; 326 | /* End XCBuildConfiguration section */ 327 | 328 | /* Begin XCConfigurationList section */ 329 | FC83F3FE1C3BFA8600EC8003 /* Build configuration list for PBXProject "ChannelEditDemo" */ = { 330 | isa = XCConfigurationList; 331 | buildConfigurations = ( 332 | FC83F4181C3BFA8700EC8003 /* Debug */, 333 | FC83F4191C3BFA8700EC8003 /* Release */, 334 | ); 335 | defaultConfigurationIsVisible = 0; 336 | defaultConfigurationName = Release; 337 | }; 338 | FC83F41A1C3BFA8700EC8003 /* Build configuration list for PBXNativeTarget "ChannelEditDemo" */ = { 339 | isa = XCConfigurationList; 340 | buildConfigurations = ( 341 | FC83F41B1C3BFA8700EC8003 /* Debug */, 342 | FC83F41C1C3BFA8700EC8003 /* Release */, 343 | ); 344 | defaultConfigurationIsVisible = 0; 345 | defaultConfigurationName = Release; 346 | }; 347 | /* End XCConfigurationList section */ 348 | }; 349 | rootObject = FC83F3FB1C3BFA8600EC8003 /* Project object */; 350 | } 351 | -------------------------------------------------------------------------------- /ChannelEditDemo/LRLChannelEdit/LRLChannelEditController.m: -------------------------------------------------------------------------------- 1 | // 2 | // LRLChannelEditController.m 3 | // V1_Circle 4 | // 5 | // Created by 刘瑞龙 on 15/11/2. 6 | // Copyright © 2015年 com.Dmeng. All rights reserved. 7 | // 8 | 9 | #import "LRLTouchView.h" 10 | #import "UIImage+LRLBundle.h" 11 | #import "LRLChannelUnitModel.h" 12 | #import "LRLChannelEditController.h" 13 | 14 | //左右边距 15 | #define EdgeX 5 16 | #define TopEdge 30 17 | 18 | //每行频道的个数 19 | #define ButtonCountOneRow 4 20 | #define ButtonHeight (ButtonWidth * 4/9) 21 | #define LocationWidth (ScreenWidth - EdgeX * 2) 22 | #define ButtonWidth (LocationWidth/ButtonCountOneRow) 23 | #define ScreenWidth ([UIScreen mainScreen].bounds.size.width) 24 | #define ScreenHeight ([UIScreen mainScreen].bounds.size.height) 25 | #define TitleSize 12.0 26 | #define EditTextSize 9.0 27 | 28 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 29 | 30 | 31 | @interface LRLChannelEditController () 32 | { 33 | BOOL _isEditing; 34 | CGPoint _oldCenter; 35 | NSInteger _moveIndex; 36 | } 37 | @property (nonatomic, strong) NSMutableArray *topDataSource; 38 | @property (nonatomic, strong) NSMutableArray *bottomDataSource; 39 | 40 | @property (nonatomic, strong) NSMutableArray *topViewArr; 41 | @property (nonatomic, strong) NSMutableArray *bottomViewArr; 42 | 43 | @property (nonatomic, weak) IBOutlet UILabel *topLabel; 44 | @property (nonatomic, assign) CGFloat topHeight; 45 | 46 | @property (nonatomic, strong) UILabel *bottomLabel; 47 | @property (nonatomic, assign) CGFloat bottomHeight; 48 | 49 | @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; 50 | @property (nonatomic, weak) IBOutlet UIButton *editButton; 51 | @property (nonatomic, weak) IBOutlet UILabel *editAlertLabel; 52 | @property (nonatomic, strong) LRLTouchView *clearView; 53 | @property (nonatomic, strong) LRLChannelUnitModel *placeHolderModel; 54 | @property (nonatomic, strong) LRLChannelUnitModel *touchingModel; 55 | 56 | @property (nonatomic, strong) LRLChannelUnitModel *initialIndexModel; 57 | @property (nonatomic, strong) LRLTouchView *initalTouchView; 58 | @property (nonatomic, assign) NSInteger locationIndex; 59 | 60 | @end 61 | 62 | @implementation LRLChannelEditController 63 | 64 | -(id)initWithTopDataSource:(NSArray *)topDataArr andBottomDataSource:(NSArray *)bottomDataSource andInitialIndex:(NSInteger)initialIndex{ 65 | if (self = [super initWithNibName:@"LRLChannelEditController" bundle:[NSBundle bundleForClass:self.class]]) { 66 | self.topDataSource = [NSMutableArray arrayWithArray:topDataArr]; 67 | self.bottomDataSource = [NSMutableArray arrayWithArray:bottomDataSource]; 68 | self.fixedCount = 0; 69 | self.locationIndex = initialIndex; 70 | } 71 | return self; 72 | } 73 | - (void)viewDidLoad { 74 | [super viewDidLoad]; 75 | self.view.backgroundColor = UIColorFromRGB(0xf5f5f5); 76 | self.automaticallyAdjustsScrollViewInsets = NO; 77 | [self configUI]; 78 | } 79 | 80 | -(void)configUI{ 81 | self.topViewArr = [NSMutableArray array]; 82 | self.bottomViewArr = [NSMutableArray array]; 83 | self.scrollView.backgroundColor = UIColorFromRGB(0xf5f5f5); 84 | 85 | //上面的标题 86 | self.topLabel.text = @"我的栏目"; 87 | self.topLabel.font = [UIFont boldSystemFontOfSize:TitleSize]; 88 | 89 | self.editAlertLabel.textColor = UIColorFromRGB(0xc0c0c0); 90 | self.editAlertLabel.font = [UIFont systemFontOfSize:EditTextSize]; 91 | self.editAlertLabel.hidden = YES; 92 | 93 | [self.editButton addTarget:self action:@selector(editOrderAct:) forControlEvents:UIControlEventTouchUpInside]; 94 | 95 | for (int i = 0; i < self.topDataSource.count; ++i) { 96 | LRLTouchView *touchView = [[LRLTouchView alloc] initWithFrame:CGRectMake(5 + i%ButtonCountOneRow * ButtonWidth, TopEdge + i/ButtonCountOneRow * ButtonHeight, ButtonWidth, ButtonHeight)]; 97 | touchView.userInteractionEnabled = YES; 98 | 99 | LRLChannelUnitModel *model = self.topDataSource[i]; 100 | touchView.contentLabel.text = model.name; 101 | if (i < self.fixedCount) { //位于前两个的频道不添加任何手势, 并且文字颜色为灰色 102 | touchView.contentLabel.textColor = UIColorFromRGB(0xc0c0c0); 103 | touchView.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(defaultTopTap:)]; 104 | [touchView addGestureRecognizer:touchView.tap]; 105 | }else{ 106 | touchView.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topTapAct:)]; 107 | [touchView addGestureRecognizer:touchView.tap]; 108 | 109 | touchView.pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(topPanAct:)]; 110 | touchView.pan.enabled = NO; 111 | [touchView addGestureRecognizer:touchView.pan]; 112 | 113 | touchView.longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapAct:)]; 114 | [touchView addGestureRecognizer:touchView.longPress]; 115 | } 116 | 117 | if (self.locationIndex == i) { //蓝色 //008dff 118 | touchView.contentLabel.textColor = UIColorFromRGB(0x008dff); 119 | self.initialIndexModel = self.topDataSource[i]; 120 | self.initalTouchView = touchView; 121 | } 122 | 123 | [self.scrollView addSubview:touchView]; 124 | [self.topViewArr addObject:touchView]; 125 | } 126 | 127 | //下面的标题 128 | self.bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,TopEdge + 25 + self.topHeight, 150, 20)]; 129 | self.bottomLabel.textAlignment = NSTextAlignmentLeft; 130 | self.bottomLabel.text = @"点击添加更过栏目"; 131 | self.bottomLabel.font = [UIFont boldSystemFontOfSize:TitleSize]; 132 | [self.scrollView addSubview:self.bottomLabel]; 133 | 134 | CGFloat startHeight = self.bottomLabel.frame.origin.y + 20 + 10; 135 | 136 | for (int i = 0; i < self.bottomDataSource.count; ++i) { 137 | LRLTouchView *touchView = [[LRLTouchView alloc] initWithFrame:CGRectMake(EdgeX + i%ButtonCountOneRow * ButtonWidth, startHeight + i/ButtonCountOneRow * ButtonHeight, ButtonWidth, ButtonHeight)]; 138 | LRLChannelUnitModel *model = self.bottomDataSource[i]; 139 | touchView.contentLabel.text = model.name; 140 | touchView.userInteractionEnabled = YES; 141 | touchView.contentLabel.textAlignment = NSTextAlignmentCenter; 142 | [self.scrollView addSubview:touchView]; 143 | [self.bottomViewArr addObject:touchView]; 144 | 145 | touchView.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bottomTapAct:)]; 146 | [touchView addGestureRecognizer:touchView.tap]; 147 | } 148 | self.scrollView.contentSize = CGSizeMake(ScreenWidth, 85 + self.topHeight + self.bottomHeight + ButtonHeight); 149 | } 150 | #pragma mark - 重新布局下边 151 | -(void)reconfigBottomView{ 152 | CGFloat startHeight = self.bottomLabel.frame.origin.y + 20 + 10; 153 | for (int i = 0; i < self.bottomViewArr.count; ++i) { 154 | LRLTouchView *touchView = self.bottomViewArr[i]; 155 | touchView.frame = CGRectMake(EdgeX + i%ButtonCountOneRow * ButtonWidth, startHeight + i/ButtonCountOneRow * ButtonHeight, ButtonWidth, ButtonHeight); 156 | } 157 | } 158 | #pragma mark - 重新布局上边 159 | -(void)reconfigTopView{ 160 | for (int i = 0; i < self.topViewArr.count; ++i) { 161 | LRLTouchView *touchView = self.topViewArr[i]; 162 | touchView.frame = CGRectMake(EdgeX + i%ButtonCountOneRow * ButtonWidth, TopEdge + i/ButtonCountOneRow*ButtonHeight, ButtonWidth, ButtonHeight); 163 | } 164 | } 165 | 166 | #pragma mark - 从上到下 167 | -(void)topTapAct:(UITapGestureRecognizer *)tap{ 168 | LRLTouchView *touchView = (LRLTouchView *)tap.view; 169 | NSInteger index = [self.topViewArr indexOfObject:touchView]; 170 | if (_isEditing) { 171 | [self.scrollView bringSubviewToFront:touchView]; 172 | //获取点击view的位置 173 | [self.bottomViewArr insertObject:touchView atIndex:0]; 174 | [self.topViewArr removeObject:touchView]; 175 | //为了安全, 加判断 176 | if (index < self.topDataSource.count) { 177 | LRLChannelUnitModel *cModel = self.topDataSource[index]; 178 | cModel.isTop = NO; 179 | [self.bottomDataSource insertObject:cModel atIndex:0]; 180 | [self.topDataSource removeObjectAtIndex:index]; 181 | } 182 | 183 | [UIView animateWithDuration:0.3 animations:^{ 184 | self.bottomLabel.frame = CGRectMake(10, TopEdge + 25 + self.topHeight, 200, 20); 185 | [self reconfigTopView]; 186 | [self reconfigBottomView]; 187 | touchView.closeImageView.hidden = YES; 188 | }]; 189 | 190 | [touchView.pan removeTarget:self action:@selector(topPanAct:)]; 191 | [touchView removeGestureRecognizer:touchView.pan]; 192 | touchView.pan = nil; 193 | 194 | [touchView.longPress removeTarget:self action:@selector(longTapAct:)]; 195 | [touchView removeGestureRecognizer:touchView.longPress]; 196 | touchView.longPress = nil; 197 | 198 | [touchView.tap removeTarget:self action:@selector(topTapAct:)]; 199 | [touchView.tap addTarget:self action:@selector(bottomTapAct:)]; 200 | }else{ 201 | [self returnToHomeWithIndex:index]; 202 | } 203 | } 204 | #pragma mark - 点击上边前两个按钮 205 | -(void)defaultTopTap:(UITapGestureRecognizer *)tap{ 206 | if (!_isEditing) { 207 | LRLTouchView *touchView = (LRLTouchView *)tap.view; 208 | NSInteger index = [self.topViewArr indexOfObject:touchView]; 209 | [self returnToHomeWithIndex:index]; 210 | } 211 | } 212 | #pragma mark - 返回到home页面, 带有点击的某个index 213 | -(void)returnToHomeWithIndex:(NSInteger)index{ 214 | if (self.chooseIndexBlock) { 215 | self.chooseIndexBlock(index, self.topDataSource, self.bottomDataSource); 216 | } 217 | [self dismissViewControllerAnimated:YES completion:^{ 218 | [self updateTOsql]; 219 | }]; 220 | } 221 | #pragma mark - 从下到上 222 | -(void)bottomTapAct:(UITapGestureRecognizer *)tap{ 223 | LRLTouchView *touchView = (LRLTouchView *)tap.view; 224 | [self.scrollView bringSubviewToFront:touchView]; 225 | NSInteger index = [self.bottomViewArr indexOfObject:touchView]; 226 | [self.topViewArr addObject:touchView]; 227 | [self.bottomViewArr removeObject:touchView]; 228 | //为了安全, 加判断 229 | if (index < self.bottomDataSource.count) { 230 | LRLChannelUnitModel *model = self.bottomDataSource[index]; 231 | model.isTop = YES; 232 | if (model == self.initialIndexModel) { 233 | if (_isEditing) { 234 | }else{ 235 | touchView.contentLabel.textColor = UIColorFromRGB(0x008dff); 236 | } 237 | } 238 | [self.topDataSource addObject:model]; 239 | [self.bottomDataSource removeObject:model]; 240 | } 241 | 242 | NSInteger i = self.topViewArr.count - 1; 243 | [UIView animateWithDuration:0.3 animations:^{ 244 | touchView.frame = CGRectMake(EdgeX + i%ButtonCountOneRow * ButtonWidth, TopEdge + i/ButtonCountOneRow*ButtonHeight, ButtonWidth, ButtonHeight); 245 | self.bottomLabel.frame = CGRectMake(10, TopEdge + 25 + self.topHeight, 200, 20); 246 | [self reconfigBottomView]; 247 | touchView.closeImageView.hidden = !_isEditing; 248 | }]; 249 | 250 | touchView.pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(topPanAct:)]; 251 | [touchView addGestureRecognizer:touchView.pan]; 252 | touchView.pan.enabled = _isEditing; 253 | 254 | touchView.longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapAct:)]; 255 | [touchView addGestureRecognizer:touchView.longPress]; 256 | 257 | [touchView.tap removeTarget:self action:@selector(bottomTapAct:)]; 258 | [touchView.tap addTarget:self action:@selector(topTapAct:)]; 259 | } 260 | 261 | -(BOOL)outRange:(CGPoint)point{ 262 | CGFloat x = point.x; 263 | CGFloat y =point.y; 264 | // return (x < EdgeX || x > ScreenWidth - EdgeX || y < TopEdge || y > TopEdge + self.topHeight || (y < (TopEdge + ButtonHeight) && x < (EdgeX + 2 * ButtonWidth))); 265 | 266 | NSUInteger line = (self.fixedCount / (ButtonCountOneRow + 1) + 1); 267 | return (x < EdgeX || x > ScreenWidth - EdgeX || y < TopEdge || y > TopEdge + self.topHeight || (y < TopEdge + line * ButtonHeight && x < (EdgeX + (self.fixedCount - (line - 1) * ButtonCountOneRow) * ButtonWidth))); 268 | } 269 | 270 | #pragma mark - 拖拽手势 271 | -(void)topPanAct:(UIPanGestureRecognizer *)pan{ 272 | LRLTouchView *touchView = (LRLTouchView *)pan.view; 273 | [self.scrollView bringSubviewToFront:touchView]; 274 | static int staticIndex = 0; 275 | if (pan.state == UIGestureRecognizerStateBegan) { 276 | [touchView inOrOutTouching:YES]; 277 | //记录移动的label最初的index 278 | _moveIndex = [self.topViewArr indexOfObject:touchView]; 279 | if (_moveIndex < self.topDataSource.count) { 280 | self.touchingModel = self.topDataSource[_moveIndex]; 281 | } 282 | [self.topViewArr removeObject:touchView]; 283 | if (self.touchingModel) { 284 | [self.topDataSource removeObject:self.touchingModel]; 285 | [self.topDataSource addObject:self.placeHolderModel]; 286 | } 287 | _oldCenter = touchView.center; 288 | }else if(pan.state == UIGestureRecognizerStateChanged){ 289 | CGPoint movePoint = [pan translationInView:self.scrollView]; 290 | touchView.center = CGPointMake(_oldCenter.x + movePoint.x, _oldCenter.y + movePoint.y); 291 | CGFloat x = touchView.center.x; 292 | CGFloat y = touchView.center.y; 293 | //没有超出范围 294 | if (![self outRange:touchView.center]) { 295 | //记录移动过程中label所处的index 296 | int index = ((int)((y - TopEdge)/ButtonHeight)) * ButtonCountOneRow + (int)(x - EdgeX)/ButtonWidth; 297 | //当index发生改变时, 插入占位的label, 重新布局UI 298 | if (staticIndex !=index) { 299 | staticIndex = index; 300 | if (staticIndex < self.topViewArr.count && staticIndex >= 0) { 301 | if ([self.topViewArr containsObject:self.clearView]) { 302 | [self.topViewArr removeObject:self.clearView]; 303 | } 304 | [self.topViewArr insertObject:self.clearView atIndex:staticIndex]; 305 | if (!self.clearView.superview) { 306 | [self.scrollView addSubview:self.clearView]; 307 | [self.scrollView sendSubviewToBack:self.clearView]; 308 | } 309 | self.clearView.frame = CGRectMake(EdgeX + staticIndex%ButtonCountOneRow * ButtonWidth, TopEdge + staticIndex/ButtonCountOneRow*ButtonHeight, ButtonWidth, ButtonHeight); 310 | [UIView animateWithDuration:0.5 animations:^{ 311 | [self reconfigTopView]; 312 | }]; 313 | }else{ 314 | } 315 | } 316 | } 317 | }else if(pan.state == UIGestureRecognizerStateEnded){ 318 | [touchView inOrOutTouching:NO]; 319 | CGFloat x = touchView.center.x; 320 | CGFloat y = touchView.center.y; 321 | if ([self outRange:touchView.center]) { 322 | NSLog(@"超出范围"); 323 | [UIView animateWithDuration:0.5 animations:^{ 324 | touchView.center = _oldCenter; 325 | }]; 326 | }else{ 327 | _moveIndex = ((int)((y - TopEdge)/ButtonHeight)) * ButtonCountOneRow + (int)(x - EdgeX)/ButtonWidth; 328 | } 329 | staticIndex = 0; 330 | if ([self.topViewArr containsObject:self.clearView]) { 331 | [self.topViewArr removeObject:self.clearView]; 332 | if (self.clearView.superview) { 333 | [self.clearView removeFromSuperview]; 334 | } 335 | } 336 | if ([self.topDataSource containsObject:self.placeHolderModel]) { 337 | [self.topDataSource removeObject:self.placeHolderModel]; 338 | } 339 | if (_moveIndex < self.topViewArr.count && _moveIndex >= 0 ) { 340 | [self.topViewArr insertObject:touchView atIndex:_moveIndex]; 341 | if (_moveIndex < self.topDataSource.count && self.touchingModel) { 342 | [self.topDataSource insertObject:self.touchingModel atIndex:_moveIndex]; 343 | } 344 | }else{ 345 | [self.topViewArr addObject:touchView]; 346 | if (self.touchingModel) { 347 | [self.topDataSource removeObject:self.placeHolderModel]; 348 | [self.topDataSource addObject:self.touchingModel]; 349 | } 350 | } 351 | [UIView animateWithDuration:0.3 animations:^{ 352 | [self reconfigTopView]; 353 | }]; 354 | }else if(pan.state == UIGestureRecognizerStateCancelled){ 355 | }else if(pan.state == UIGestureRecognizerStateFailed){ 356 | } 357 | } 358 | #pragma mark - 长按手势 359 | -(void)longTapAct:(UILongPressGestureRecognizer *)longPress{ 360 | LRLTouchView *touchView = (LRLTouchView *)longPress.view; 361 | [self.scrollView bringSubviewToFront:touchView]; 362 | static CGPoint touchPoint; 363 | static CGFloat offsetX; 364 | static CGFloat offsetY; 365 | static NSInteger staticIndex = 0; 366 | if (longPress.state == UIGestureRecognizerStateBegan) { 367 | _isEditing = YES; 368 | [touchView inOrOutTouching:YES]; 369 | [self inOrOutEditWithEditing:_isEditing]; 370 | //记录移动的label最初的index 371 | _moveIndex = [self.topViewArr indexOfObject:touchView]; 372 | if (_moveIndex < self.topDataSource.count) { 373 | self.touchingModel = self.topDataSource[_moveIndex]; 374 | } 375 | [self.topViewArr removeObject:touchView]; 376 | if (self.touchingModel) { 377 | [self.topDataSource removeObject:self.touchingModel]; 378 | [self.topDataSource addObject:self.placeHolderModel]; 379 | } 380 | _oldCenter = touchView.center; 381 | 382 | //这是为了计算手指在Label上的偏移位置 383 | touchPoint = [longPress locationInView:touchView]; 384 | CGPoint centerPoint = CGPointMake(ButtonWidth/2, ButtonHeight/2); 385 | offsetX = touchPoint.x - centerPoint.x; 386 | offsetY = touchPoint.y - centerPoint.y; 387 | 388 | CGPoint movePoint = [longPress locationInView:self.scrollView]; 389 | [UIView animateWithDuration:0.1 animations:^{ 390 | touchView.center = CGPointMake(movePoint.x - offsetX, movePoint.y - offsetY); 391 | }]; 392 | }else if(longPress.state == UIGestureRecognizerStateChanged){ 393 | CGPoint movePoint = [longPress locationInView:self.scrollView]; 394 | touchView.center = CGPointMake(movePoint.x - offsetX, movePoint.y - offsetY); 395 | 396 | CGFloat x = touchView.center.x; 397 | CGFloat y = touchView.center.y; 398 | //没有超出范围 399 | if (![self outRange:touchView.center]) { 400 | //记录移动过程中label所处的index 401 | int index = ((int)((y - TopEdge)/ButtonHeight)) * ButtonCountOneRow + (int)(x - EdgeX)/ButtonWidth; 402 | 403 | //当index发生改变时, 插入占位的label, 重新布局UI 404 | if (staticIndex !=index) { 405 | staticIndex = index; 406 | if (staticIndex < self.topViewArr.count && staticIndex >= 0) { 407 | if ([self.topViewArr containsObject:self.clearView]) { 408 | [self.topViewArr removeObject:self.clearView]; 409 | } 410 | [self.topViewArr insertObject:self.clearView atIndex:staticIndex]; 411 | if (!self.clearView.superview) { 412 | [self.scrollView addSubview:self.clearView]; 413 | [self.scrollView sendSubviewToBack:self.clearView]; 414 | } 415 | self.clearView.frame = CGRectMake(EdgeX + staticIndex%ButtonCountOneRow * ButtonWidth, TopEdge + staticIndex/ButtonCountOneRow*ButtonHeight, ButtonWidth, ButtonHeight); 416 | [UIView animateWithDuration:0.5 animations:^{ 417 | [self reconfigTopView]; 418 | }]; 419 | }else{ 420 | NSLog(@"计算index 超出范围"); 421 | } 422 | } 423 | } 424 | }else if(longPress.state == UIGestureRecognizerStateEnded){ 425 | [touchView inOrOutTouching:NO]; 426 | CGFloat x = touchView.center.x; 427 | CGFloat y = touchView.center.y; 428 | if ([self outRange:touchView.center]) { 429 | NSLog(@"长按手势结束: 超出范围"); 430 | [UIView animateWithDuration:0.5 animations:^{ 431 | touchView.center = _oldCenter; 432 | }]; 433 | }else{ 434 | _moveIndex = ((int)((y - TopEdge)/ButtonHeight)) * ButtonCountOneRow + (int)(x - EdgeX)/ButtonWidth; 435 | } 436 | staticIndex = 0; 437 | if ([self.topViewArr containsObject:self.clearView]) { 438 | [self.topViewArr removeObject:self.clearView]; 439 | if (self.clearView.superview) { 440 | [self.clearView removeFromSuperview]; 441 | } 442 | } 443 | if ([self.topDataSource containsObject:self.placeHolderModel]) { 444 | [self.topDataSource removeObject:self.placeHolderModel]; 445 | } 446 | if (_moveIndex < self.topViewArr.count && _moveIndex >= 0) { 447 | [self.topViewArr insertObject:touchView atIndex:_moveIndex]; 448 | if (_moveIndex < self.topDataSource.count && self.touchingModel) { 449 | [self.topDataSource insertObject:self.touchingModel atIndex:_moveIndex]; 450 | } 451 | }else{ 452 | [self.topViewArr addObject:touchView]; 453 | if (self.touchingModel) { 454 | [self.topDataSource addObject:self.touchingModel]; 455 | } 456 | } 457 | [UIView animateWithDuration:0.3 animations:^{ 458 | [self reconfigTopView]; 459 | }]; 460 | }else if(longPress.state == UIGestureRecognizerStateCancelled){ 461 | }else if(longPress.state == UIGestureRecognizerStateFailed){ 462 | } 463 | } 464 | 465 | #pragma mark - 用于占位的透明label 466 | -(LRLTouchView *)clearView{ 467 | if (!_clearView) { 468 | _clearView = [[LRLTouchView alloc] init]; 469 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, ButtonWidth - 10, ButtonHeight - 10)]; 470 | imageView.image = [UIImage imageMyBundleNamed:@"lanmu2"]; 471 | [_clearView addSubview:imageView]; 472 | _clearView.backgroundColor = [UIColor clearColor]; 473 | [_clearView.contentLabel removeFromSuperview]; 474 | } 475 | return _clearView; 476 | } 477 | #pragma mark - 用于占位的model, 由于计算位置有问题 478 | -(LRLChannelUnitModel *)placeHolderModel{ 479 | if (!_placeHolderModel) { 480 | _placeHolderModel = [[LRLChannelUnitModel alloc] init]; 481 | } 482 | return _placeHolderModel; 483 | } 484 | #pragma mark - 充当计算属性使用 485 | -(CGFloat)topHeight{ 486 | if (self.topDataSource.count < ButtonCountOneRow) { 487 | return ButtonHeight; 488 | }else{ 489 | return ((self.topDataSource.count - 1)/ButtonCountOneRow + 1) * ButtonHeight; 490 | } 491 | } 492 | -(CGFloat)bottomHeight{ 493 | if (self.bottomDataSource.count < ButtonCountOneRow) { 494 | return ButtonHeight; 495 | }else{ 496 | return ((self.bottomDataSource.count - 1)/ButtonCountOneRow + 1) * ButtonHeight;; 497 | } 498 | } 499 | #pragma mark - 点击编辑或者完成按钮 500 | -(void)editOrderAct:(UIButton *)button{ 501 | _isEditing = !_isEditing; 502 | [self inOrOutEditWithEditing:_isEditing]; 503 | if (!_isEditing) { //点击完成 504 | } 505 | } 506 | #pragma mark - 进入或者退出编辑状态 507 | -(void)inOrOutEditWithEditing:(BOOL)isEditing{ 508 | if (isEditing) { 509 | [self.editButton setBackgroundImage:[UIImage imageMyBundleNamed:@"finsh"] forState:UIControlStateNormal]; 510 | [self.editButton setBackgroundImage:[UIImage imageMyBundleNamed:@"finsh-1"] forState:UIControlStateHighlighted]; 511 | 512 | if (self.initalTouchView) { 513 | if (self.locationIndex > 1) { 514 | self.initalTouchView.contentLabel.textColor = UIColorFromRGB(0X333333); 515 | }else{ 516 | self.initalTouchView.contentLabel.textColor = UIColorFromRGB(0xc0c0c0); 517 | } 518 | } 519 | 520 | self.editAlertLabel.hidden = NO; 521 | for (int i = 0; i < self.topViewArr.count; ++i) { 522 | LRLTouchView *touchView = self.topViewArr[i]; 523 | if (touchView.pan) { 524 | touchView.pan.enabled = YES; 525 | touchView.closeImageView.hidden = NO; 526 | } 527 | } 528 | }else{ 529 | [self.editButton setBackgroundImage:[UIImage imageMyBundleNamed:@"reorder"] forState:UIControlStateNormal]; 530 | [self.editButton setBackgroundImage:[UIImage imageMyBundleNamed:@"reorder-1"] forState:UIControlStateHighlighted]; 531 | 532 | if (self.initalTouchView && self.initialIndexModel.isTop) { 533 | self.initalTouchView.contentLabel.textColor = UIColorFromRGB(0x008dff); 534 | } 535 | self.editAlertLabel.hidden = YES; 536 | for (int i = 0; i < self.topViewArr.count; ++i) { 537 | LRLTouchView *touchView = self.topViewArr[i]; 538 | if (touchView.pan) { 539 | touchView.pan.enabled = NO; 540 | touchView.closeImageView.hidden = YES; 541 | } 542 | } 543 | } 544 | } 545 | 546 | #pragma mark - 预留的同步到本地的方法 547 | -(void)updateTOsql{ 548 | NSMutableArray *arr = [NSMutableArray arrayWithArray:self.topDataSource]; 549 | [arr addObjectsFromArray:self.bottomDataSource]; 550 | } 551 | 552 | #pragma mark - 点击关闭按钮 553 | - (IBAction)closeButtonAct:(id)sender { 554 | if (self.initialIndexModel && self.initialIndexModel.isTop) { 555 | if ([self.topDataSource containsObject:self.initialIndexModel]) { 556 | if (self.chooseIndexBlock) { 557 | self.chooseIndexBlock([self.topDataSource indexOfObject:self.initialIndexModel], self.topDataSource, self.bottomDataSource); 558 | } 559 | } 560 | }else{ 561 | if (self.removeInitialIndexBlock) { 562 | self.removeInitialIndexBlock(self.topDataSource, self.bottomDataSource); 563 | } 564 | } 565 | [self dismissViewControllerAnimated:YES completion:^{ 566 | [self updateTOsql]; 567 | }]; 568 | } 569 | 570 | @end 571 | --------------------------------------------------------------------------------