1. 程式人生 > >關於UITableView邊框及分割線調為1個畫素

關於UITableView邊框及分割線調為1個畫素

1.需要#import <QuartzCore/QuartzCore.h>  和1個畫素的圖片線 UITableView的型別必須為 UITableViewStylePlain 

1個畫素的線

2.設定UITableView 的屬性

_myTableView = [[UITableViewalloc]initWithFrame:CGRectMake(101030087style:UITableViewStylePlain];

    [_myTableViewsetBackgroundView:nil];

    [_myTableViewsetBackgroundColor:[

UIColorwhiteColor]];

    [_myTableViewsetDataSource:self];

    [_myTableViewsetDelegate:self];

_myTableView.layer.cornerRadius = 2.0f;//(值越大,角就越圓)

_myTableView.layer.masksToBounds = YES;//方法告訴layer將位於它之下的layer都遮蓋住

_myTableView.layer.borderWidth = 0.5;//邊框寬度

_myTableView.layer.borderColor = [RGBA(224

2242241CGColor];

//    [_myTableView setSeparatorColor:[UIColor redColor]];

    [_myTableViewsetSeparatorStyle:UITableViewCellSeparatorStyleNone];

3.設定cell的屬性

static NSString *cellIndetify = @"cell";

UITableViewCell *cell = nil;

    cell = [tableView dequeueReusableCellWithIdentifier:cellIndetify];

    if (cell == nil) {

        cell = [[[UITableViewCellallocinitWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:cellIndetify]autorelease];

//        cell.selectionStyle = UITableViewCellSelectionStyleBlue;

//        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

//        cell.accessoryType = UITableViewCellAccessoryNone;

//        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        cell.backgroundColor = [UIColorclearColor];

        [cell.contentViewaddSubview:[[[UIImageViewalloc]initWithImage:WXImageRes(@"sigle_line")]autorelease]];

    }