Closed ghost closed 10 years ago
Fixed it my own, heres the solution in case anyone needs this:
- (void) setCustomHeaderViewWithTitle : (NSString*) title
{
UIView *headerLabelContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 23)];
headerLabelContainerView.backgroundColor = [UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1];
headerLabelContainerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.translatesAutoresizingMaskIntoConstraints = NO;
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.font = [UIFont boldSystemFontOfSize:24];
headerLabel.textColor = [UIColor blackColor];
headerLabel.text = title;
[headerLabelContainerView addSubview:headerLabel];
NSDictionary *views = NSDictionaryOfVariableBindings(headerLabel);
[headerLabelContainerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(20)-[headerLabel]-(>=0)-|" options:0 metrics:nil views:views]];
[headerLabelContainerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[headerLabel]|" options:0 metrics:nil views:views]];
[self setHeaderView: headerLabelContainerView];
}
Hello,
i'm trying to enhance QSection with a custom method called setCustomHeaderViewWithTitle: which should create a custom header view for qsections.
Heres the code:
Usage is the following:
Unfortunately it doesn't work. What am I doing wrong?
Thanks in advance