UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制

来源:互联网 发布:mac如何不在桌面显示 编辑:程序博客网 时间:2024/05/22 10:47

1、在viewDidLoad中添加

// 重写UITableView的方法是分割线从最左侧开始    if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {                [_tableView setSeparatorInset:UIEdgeInsetsZero];    }    if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {        [_tableView setLayoutMargins:UIEdgeInsetsZero];    }

2、重写下面的方法

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

其它:

关于UITableView中右箭头

cell.accessoryType = UITableViewCellAccessoryNone;//cell没有任何的样式cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;//cell的右边有一个小箭头,距离右边有十几像素;cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;//cell右边有一个蓝色的圆形button;cell.accessoryType = UITableViewCellAccessoryCheckmark;//cell右边的形状是对号;

UITableView分割线样式与颜色

_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;_tableView.separatorColor = [UIColor colorWithRed:221/255.0f green:221/255.0f blue:221/255.0f alpha:0.5];

UITableViewCell中ImageView的大小和位置

UIImage *icon = [UIImage imageNamed:[dic objectForKey:@"image"]];CGSize itemSize = CGSizeMake(40, 40);UIGraphicsBeginImageContextWithOptions(itemSize, NO,0.0);CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);[icon drawInRect:imageRect];cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();




0 0
原创粉丝点击