iOS小细节(二)

1.自定义tabViewCell的选中图片

   if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {

        UIImage *image = [UIImage imageNamed:@"select"];

        UIButton * button = [UIButtonbuttonWithType:UIButtonTypeCustom];

        CGRect frame =CGRectMake(0.0,0.0,image.size.width,image.size.height);

        button.frame = frame;

        [button setBackgroundImage:imageforState:UIControlStateNormal];

        button.backgroundColor = [UIColor clearColor];

        cell.accessoryView = button;

    }else

        {

        cell.accessoryType = UITableViewCellAccessoryNone;

        UIButton * button = [UIButtonbuttonWithType:UIButtonTypeCustom];

        button.backgroundColor = [UIColor clearColor];

        cell.accessoryView = button;

        }




2.导航栏下面的横线改变颜色

 

 [[UINavigationBar appearancesetBackgroundImage:[UIImageimageWithColor:[UIColor whiteColor]]forBarPosition:UIBarPositionAnybarMetrics:UIBarMetricsDefault];

    //[[UINavigationBar appearance] setShadowImage:[UIImage new]];

 

    [[UINavigationBar appearancesetShadowImage:[UIImageimageWithColor:RGBA(212212212,.3)]];




+ (UIImage *)imageWithColor:(UIColor *)color

{

    CGRect rect = CGRectMake(0.0f0.0f1.0f1.0f);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

    return image;

 

}



3.tabbar上面的横线改变颜色


    //修改tabbar黑边颜色

    UIImage *img2 = [UIImage initWithColor2:RGB(255, 255, 255) rect:CGRectMake(0, 0, SCREEN_WIDTH, 44)];

    UIImage *img = [UIImage initWithColor:RGB(221, 221, 221) rect:CGRectMake(0,0, SCREEN_WIDTH, 0.3)];//.5

    [self.tabBar setBackgroundImage:img2];

    [self.tabBar setShadowImage:img];

    [self.tabBar setBackgroundColor:[UIColor whiteColor]];



4.设置状态栏背景颜色

    [self setStatusBarBackgroundColor:[UIColor whiteColor]];


//设置状态栏颜色

- (void)setStatusBarBackgroundColor:(UIColor *)color {

    

    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {

        statusBar.backgroundColor = color;

    }

}



5.剪裁图片

 //如果子视图的范围超出了父视图的边界,那么超出的部分就会被裁剪掉。

        [self.avatar setClipsToBounds:YES];


6.只执行一 次

 static dispatch_once_t disOnce;

    

    dispatch_once(&disOnce,^ {

        

        //只执行一次的代码

        

    });



6.设置组头和组尾的颜色

//设置组头和组尾部的颜色

-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section

{

    //YourColor: view.tintColor = WTGayColor(240);

    view.tintColor = [UIColor at_whiteColor];

}


-(void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section

{

    view.tintColor = [UIColor at_whiteColor];

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值