IOS开发小技巧

1、去掉UITableView没有内容显示的cell

self.tableView.tableFooterView = [UIView new];

2、修改UITableView自带的线条(颜色和位置)

//ios8 设置UITableViewCell左侧默认15像素的空白
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    [self.tableView setSeparatorColor:SC_TABLEVIE_LINELIGTHT];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [self.tableView setLayoutMargins:UIEdgeInsetsZero];
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

3、单例实现方法

+ (instancetype)shareInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _manager = [[NHLManager alloc]init];
    });
    return _manager;
}

4、iOS导航栏NavigationBar设置透明,以及添加变色的动画
透明只需设置NavigationBar的背景图片为一张空图片即可

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

5、UITextField占位文字的颜色的修改(.h和.m文件实现)

@interface UITextField (TextFieldPHColor)

/**
 *  占位文字颜色
 */
@property (strong, nonatomic) UIColor *placeholderColor;

@end
@implementation UITextField (TextFieldPHColor)

- (void)setPlaceholderColor:(UIColor *)placeholderColor{
    BOOL change = NO;
    if (self.placeholder == nil) {
        self.placeholder = @" ";
        change = YES;
    }
    [self setValue:placeholderColor forKeyPath:@"placeholderLabel.textColor"];
    if (change) {
        self.placeholderColor = nil;
    }
}

- (UIColor *)placeholderColor{
    return [self valueForKey:@"placeholderLabel.textColor"];
}

@end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值