GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Coding-iOS/Coding_iOS/Controllers/EditColorViewController.m at master · coding/Coding-iOS Expand file tree/ Copy pathEditColorViewController.mMore file actions 110 lines (105 loc) · 5.02 KB / Copy pathEditColorViewController.mFile metadata and controls110 lines (105 loc) · 5.02 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 // // EditColorViewController.m // Coding_iOS // // Created by Ease on 16/2/19. // Copyright © 2016年 Coding. All rights reserved. // #import "EditColorViewController.h" #import "TPKeyboardAvoidingTableView.h" #import "TagColorEditCell.h" #import "TagColorDisplayCell.h" @interface EditColorViewController ()<UITableViewDataSource, UITableViewDelegate> @property (strong, nonatomic) TPKeyboardAvoidingTableView *myTableView; @property (strong, nonatomic) NSArray *colorList; @end @implementation EditColorViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title = @"标签颜色"; _colorList = @[@{@"name": @"灰色", @"value": @"#90A4AE"}, @{@"name": @"黄色", @"value": @"#FFC107"}, @{@"name": @"红色", @"value": @"#FF5722"}, @{@"name": @"绿色", @"value": @"#4CAF50"}, @{@"name": @"蓝色", @"value": @"#03A9F4"}, @{@"name": @"紫色", @"value": @"#AB44BC"}, ]; _myTableView = ({ TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; tableView.backgroundColor = kColorTableSectionBg; tableView.delegate = self; tableView.dataSource = self; [tableView registerClass:[TagColorEditCell class] forCellReuseIdentifier:kCellIdentifier_TagColorEditCell]; [tableView registerClass:[TagColorDisplayCell class] forCellReuseIdentifier:kCellIdentifier_TagColorDisplayCell]; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.view addSubview:tableView]; [tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }]; tableView.estimatedRowHeight = 0; tableView.estimatedSectionHeaderHeight = 0; tableView.estimatedSectionFooterHeight = 0; tableView; }); } #pragma matk Table - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return section == 0? 1: _colorList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.section == 0) { TagColorEditCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TagColorEditCell forIndexPath:indexPath]; cell.colorF.text = _curTag.color; @weakify(self); @weakify(cell); [cell.colorF.rac_textSignal subscribeNext:^(NSString *value) { if (![value hasPrefix:@"#"] || value.length != 7) { return ; } UIColor *color = [UIColor colorWithHexString:[value stringByReplacingOccurrencesOfString:@"#" withString:@"0x"]]; if (!color || ![[value uppercaseString] hasSuffix:[color hexStringFromColor]]) { return ; } @strongify(self); @strongify(cell); self.curTag.color = [value uppercaseString]; cell.colorView.backgroundColor = color; }]; cell.colorView.backgroundColor = [UIColor colorWithHexString:[_curTag.color stringByReplacingOccurrencesOfString:@"#" withString:@"0x"]]; [cell.randomBtn addTarget:self action:@selector(randomColorBtnClicked) forControlEvents:UIControlEventTouchUpInside]; [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth]; return cell; }else{ TagColorDisplayCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TagColorDisplayCell forIndexPath:indexPath]; NSDictionary *colorDict = _colorList[indexPath.row]; cell.colorView.backgroundColor = [UIColor colorWithHexString:[colorDict[@"value"] stringByReplacingOccurrencesOfString:@"#" withString:@"0x"]]; cell.colorL.text = colorDict[@"name"]; cell.accessoryType = [_curTag.color isEqualToString:colorDict[@"value"]]? UITableViewCellAccessoryCheckmark: UITableViewCellAccessoryNone; [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:CGRectGetMinX(cell.colorL.frame)]; return cell; } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.section == 1) { NSDictionary *colorDict = _colorList[indexPath.row]; _curTag.color = [colorDict[@"value"] uppercaseString]; [self.navigationController popViewControllerAnimated:YES]; } } #pragma mark Btn - (void)randomColorBtnClicked{ _curTag.color = [NSString stringWithFormat:@"#%@", [[UIColor randomColor] hexStringFromColor]]; [self.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; } @end |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |