UITableViewCell偏移

想要UITableViewCell中的文本往右移点,就是要实现水平位移,怎么能实现?

要不要自定义个cell,谢谢

可以自定义一个cell ,当然也可以通过修改cell.textLabel的frame来改变文本的位置。

文字前面加几个空格呗!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }

    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(50.0f, 10.0f, 150.0f, 20.0f)];
    [lbl setText:@"test text"];
    [cell addSubview:lbl];
    [lbl release];
    return cell;
}