TopView* topview=[[TopView alloc] initWithFrame:CGRectMake(-5,0, SCREEN_WIDTH, 44)];
topview.backgroundColor=[UIColor greenColor];
[self.view addSubview:topview];
// [topview mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.equalTo(@0);
// make.left.equalTo(@0);
// make.right.equalTo(@-0);
// make.bottom.equalTo(@-0);
// }];
self.navigationItem.titleView=topview;
#import "TopView.h"
@implementation TopView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// self.backgroundColor=[UIColor greenColor];
}
return self;
}
- (void)setFrame:(CGRect)frame {
[super setFrame:CGRectMake(-8, 0, SCREEN_WIDTH, 44)];
}
@end
网友评论