由于出现了按钮不是自己想要的尺寸布局
就是把自定义的button加在View即可
Jietu20190807-110238.png1、这是不正常的数据
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:backgroundImageFile];
UIButton* modalViewButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 21.5, 15)];
[modalViewButton addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchUpInside];
[modalViewButton setImage:backgroundImage forState:UIControlStateNormal];
UIBarButtonItem *modalBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: modalViewButton];
self.navigationItem.leftBarButtonItem = modalBarButtonItem;
2、这是正常的代码
UIButton* modalViewButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 21.5, 15)];
[modalViewButton addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchUpInside];
[modalViewButton setImage:backgroundImage forState:UIControlStateNormal];
UIView *containVew = [[UIView alloc] initWithFrame:modalViewButton.bounds];
[containVew addSubview:modalViewButton];
UIBarButtonItem *modalBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:containVew];
self.navigationItem.leftBarButtonItem = modalBarButtonItem;
7284CA8E1080D6BADDCC07B4225CE18F.png
网友评论