开发小技巧收集

IOS 控件 - UIButton 文字靠左
想要设置 uibutton 的文字的位置的时候,不能使用
btn.titleLabel.textAlignment = UITextAlignmentLeft
真正起作用的是:

btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

IOS 控件 - UItableview 刷新动画闪烁

            [UIView performWithoutAnimation:^{
                [tableview reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
            }];

IOS reactivecocoa 去除重复信号

[[RACObserve(cell.textLabel, text) takeUntil:cell.rac_prepareForReuseSignal] subscribeNext:^(id x) {
        @strongify(self);
        NSLog(@"%@", self);
    }];

IOS 点击cell alertController 延迟
a. 可以cell的selecteStyle == default;

cell.selectionStyle = UITableViewCellSelectionStyleDefault;

b. 修改背景颜色

UIView cellBlack = [[UIView alloc] initWithFrame:cell.frame];
cellBlack.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = cellBlack; 
//然后在cell里面设置: 
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
UIColor originColor = self.leftMessage.backView.backgroundColor; 
[super setSelected:selected animated:animated]; 
self.leftMessage.backView.backgroundColor = originColor; 
} 
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { 
UIColor *originColor = self.leftMessage.backView.backgroundColor; 
[super setHighlighted:highlighted animated:animated]; 
self.leftMessage.backView.backgroundColor = originColor; 
} 

c.主线成执行

[[RACObserve(cell.textLabel, text) takeUntil:cell.rac_prepareForReuseSignal]     dispatch_async(dispatch_get_main_queue(), ^{
        [self presentViewController:alertController animated:YES completion:nil];
    });

d.字符串创建类 并调用方法

    Class class = NSClassFromString(@"vc");
    if (class) {
        id obj = [[class alloc] init];
        SEL sel = NSSelectorFromString(@"vcsel");
        //检查是否有"myMethod"这个名称的方法
        if ([obj respondsToSelector:sel]) {
//            [obj performSelector:sel];
            [obj performSelector:sel withObject:nil afterDelay:0.0];
        }
    }

你可能感兴趣的:(开发小技巧收集)