我想在 bbc 新闻应用程序等视图控制器的标题中放置一个图标,以最大化和最小化字体。
我必须知道,有没有图书馆可以做到这一点?
希望这会帮助你..
UIView *customView=[[UIView alloc]initWithFrame:CGRectMake(10, 0, 40, 40)];
UIButton *btnAction =[UIButton buttonWithType:UIButtonTypeCustom];
[btnAction addTarget:self action:@selector(btnActionClick) forControlEvents:UIControlEventTouchDragInside];
[btnAction setFrame:CGRectMake(0, 0, 40, 58)];
[customView addSubview:btnAction];
UIButton *btnFont =[UIButton buttonWithType:UIButtonTypeCustom];
[btnFont addTarget:self action:@selector(btnFontClick) forControlEvents:UIControlEventTouchDragInside];
[btnAction setFrame:CGRectMake(30, 0, 40, 58)];
[customView addSubview:btnAction]
UIBarButtonItem *MessageBtn=[[UIBarButtonItem alloc]initWithCustomView:customView];
您可以使用
[self.navigationItem setRightBarButtonItem:"your button"animated:YES];
通过使用以下代码,您可以根据需要将按钮放在视图控制器的标题中。
但是要设置字体(最小化或最大化),您必须编写其他代码。
你可以为它做谷歌。
[self.navigationItem setRightBarButtonItem:"BUTTON"animated:YES];