nambar
nambar

Reputation: 573

UITableView - align cell image to top left

I have a UITableView where I set the height to be larger than default (using heightForRowAtIndexPath. The image in the cell is always 32x32 and us currently being vertically aligned to center. I'd like that the image will be at the top of the cell. I tried something like this (setting the bounds explicitly):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    
    static NSString *MyIdentifier = @"MyIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:MyIdentifier] autorelease];
        cell.imageView.bounds = CGRectMake(7,7,32,32);
    ....
    }
    ....
}

but this doesn't work. Any simple way to make it without creating a complete custom cell?

Upvotes: 0

Views: 1522

Answers (1)

MGA
MGA

Reputation: 3751

Take a look at this article here

You can do some pretty custom modifications if you play with the content view, you just need to know how to do it ;)

Upvotes: 2

Related Questions