美文网首页
投机取巧

投机取巧

作者: 毛茸茸的我总念成橡皮虾 | 来源:发表于2015-10-23 21:41 被阅读116次

    1、更改textField的clearButton样式

    UIButton *clearButton = [_nameTextField valueForKey:@"_clearButton"];

    [clearButton setImage:[UIImage imageNamed:@"emotionstore_progresscancelbtn.png"] forState:UIControlStateNormal];

    2、更改textField的placehoder的字体颜色

    [textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

    3、延迟执行

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    });

    4、获取每个tableViewCell中的按钮点击

    - (void)clickButton:(UIButton *)button event:(id)event {

    NSSet *touches = [event allTouches];

    UITouch *touch = [touches anyObject];

    CGPoint currentTouchPosition = [touch locationInView:self.tableView];

    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];

    if (indexPath != nil) {

    }

    }

    5、更改字符串属性和字体

    NSString *string = @"123ABC456";

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];

    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange:(3,3)];//更改 ABC 字符颜色为红色

    [attributedString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:15] range:NSMakeRange:(6,3)];//更改 456 字符字体大小为15号字体

    6、更改 tableView 分割线颜色和长度

    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

    [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];

    [self.tableView setSeparatorColor:[UIColor colorWithRed:0.89f green:0.89f blue:0.89f alpha:1.00f]];

    }

    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

    [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 20, 0, 20)];

    [self.tableView setSeparatorColor:[UIColor colorWithRed:0.89f green:0.89f blue:0.89f alpha:1.00f]];

    }

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    {

    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

    [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];

    [self.tableView setSeparatorColor:[UIColor colorWithRed:0.89f green:0.89f blue:0.89f alpha:1.00f]];

    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

    [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 20, 0, 20)];

    [self.tableView setSeparatorColor:[UIColor colorWithRed:0.89f green:0.89f blue:0.89f alpha:1.00f]];

    }

    }

    相关文章

      网友评论

          本文标题:投机取巧

          本文链接:https://www.haomeiwen.com/subject/uoithttx.html