请告诉我。我正试图用题词和图像将UIButton从navigationItem分配给titleView。铭文看上去很正常,但图像没有出现,刻痕在下面(铭文从中心移到右边)。
UIButton* openMenu = [UIButton buttonWithType:UIButtonTypeCustom];
[openMenu addTarget:self action:@selector(openCloseMenuAction:) forControlEvents:UIControlEventTouchUpInside];
[openMenu setTitle:@"title" forState:UIControlStateNormal];
[openMenu setImage:[UIImage imageNamed:@"downButton.png"] forState:UIControlStateNormal];
self.navigationController.navigationBar.topItem.titleView = openMenu;发布于 2016-03-04 21:29:54
在我看来,你需要给openMenu一个尺寸。你可以试试[openMenu sizeToFit],看看它的样子。
发布于 2016-03-04 21:30:09
imageEdgeInset和titleEdgeInset属性UIButton在按钮中定位标题和图像。UIButton的框架
titleButton.frame = CGRectMake(0,0,200,44);https://stackoverflow.com/questions/35806180
复制相似问题