0
안녕하세요. 사용자 정의 navigationitem 제목보기를 만들었지 만 약간 잘못 보입니다. 여기
은 응용 프로그램 실행, 그것은 제목이 중앙에 있지 않은 것을 좋아하는 경우
사용자 정의 navigationitem 제목보기 틀림 프레임
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_titleLabel=[[[UILabel alloc] init] autorelease];
[self addSubview:_titleLabel];
_actionButton=[UIButton buttonWithType:UIButtonTypeCustom];
[self addSubview:_actionButton];
[_actionButton setImage:[UIImage imageNamed:@"arrow_cal_right"] forState:UIControlStateNormal];
}
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
[_titleLabel sizeToFit];
[_actionButton sizeToFit];
CGFloat height=44;//MAX(_titleLabel.frame.size.height, _actionButton.frame.size.height);
self.frame=CGRectMake(self.frame.origin.x,
0,
_titleLabel.frame.size.width+_actionButton.frame.size.width+kMargin,
height);
_titleLabel.frame=CGRectMake(0,
(height-_titleLabel.frame.size.height)/2,
_titleLabel.frame.size.width,
_titleLabel.frame.size.height);
_actionButton.frame=CGRectMake(_titleLabel.frame.size.width+kMargin,
(height-_actionButton.frame.size.height)/2,
_actionButton.frame.size.width,
_actionButton.frame.size.height);
}
하지만이
스크린 샷이 여기에 UIView의에, 그것은 기본 사용자 정의보기를 수 있습니다 :
http://i.stack.imgur.com/yQVLr.png