Skip to content

unable to assign a custom title view #27

@andrewstephenson-v1

Description

@andrewstephenson-v1

example code to reproduce problem.

_labelPrompt = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 22)];
_labelPrompt.backgroundColor = [UIColor clearColor];
_labelPrompt.numberOfLines = 1;
_labelPrompt.font = [UIFont boldSystemFontOfSize: 14.0f];
_labelPrompt.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
_labelPrompt.textAlignment = UITextAlignmentCenter;
_labelPrompt.textColor = [UIColor whiteColor];
_labelPrompt.adjustsFontSizeToFitWidth = YES;

_labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 22, 160, 22)];
_labelTitle.backgroundColor = [UIColor clearColor];
_labelTitle.numberOfLines = 1;
_labelTitle.font = [UIFont boldSystemFontOfSize: 14.0f];
_labelTitle.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
_labelTitle.textAlignment = UITextAlignmentCenter;
_labelTitle.textColor = [UIColor whiteColor];
UIView* titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
[titleView addSubview:_labelPrompt];
[titleView addSubview:_labelTitle];

_labelPrompt.text = @"prompt";
_labelTitle.text = @"title";

if (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad) {
    self.layeredNavigationItem.rightBarButtonItem = _buttonHistory;
    self.layeredNavigationItem.titleView = titleView;
} else {
    self.navigationItem.rightBarButtonItem = _buttonHistory;
    self.navigationItem.titleView = titleView;
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions