Indented groups such as iphone contacts

I would like to have a joined table in which the first section has an application with two rows and 1 image images.

something like this: screeshot

How can i do this?

Thanks Max

+3
source share
3 answers

Other solutions require you to create your own background images and use two table views, which is not convenient. What I did was subclass UITableViewCell and indent the background view as such:

#define INDENT_WIDTH 84

...

- (void)layoutSubviews
{
    [super layoutSubviews];

    //Indent the background views.
    CGRect frame = self.backgroundView.frame;
    frame.origin.x = frame.origin.x + INDENT_WIDTH;
    frame.size.width = frame.size.width - INDENT_WIDTH;
    self.backgroundView.frame = frame;
    self.selectedBackgroundView.frame = frame;

   //Also indent the UIImageview that contains like a shadow image over the backgroundviews (in grouped tableview style only).
   for (UIView *subview in self.subviews) {
        if ([subview isKindOfClass:[UIImageView class]]) {
            CGRect frame = subview.frame;
            frame.origin.x = frame.origin.x + INDENT_WIDTH;
            frame.size.width = frame.size.width - INDENT_WIDTH;
            subview.frame = frame;
        }
   }
}

, UIImageView (, ) , , " " "".

+3
+1

:

(1) , , UITableViewStyleGrouped.

(2) UIImageView, subView (1)

(3) UITableView (Grouped Style) (1)

Set the frames of both subviews correctly and accordingly for the layout in the screenshot and use delegation for the “logical connection” of both subzones.

Edit: The background color can be achieved using the image [UIColor colorWithPatternImage: (UIImage *)]. Just crop the background from any sample application on the iphone simulator.

0
source

Source: https://habr.com/ru/post/1796329/


All Articles