Ios 左巴布托主义从画面中走出来
我已经应用了一个代码将uibutton添加到UIBarButtonim中,问题是该按钮超出了框架 代码是Ios 左巴布托主义从画面中走出来,ios,Ios,我已经应用了一个代码将uibutton添加到UIBarButtonim中,问题是该按钮超出了框架 代码是 a1 = [UIButton buttonWithType:UIButtonTypeCustom]; [a1 setFrame:CGRectMake(0.0f, 0.0f, 65.0f, 63.0f)]; [a1 addTarget:self.slideMenuController action:@selector(toggleMenu) forControl
a1 = [UIButton buttonWithType:UIButtonTypeCustom];
[a1 setFrame:CGRectMake(0.0f, 0.0f, 65.0f, 63.0f)];
[a1 addTarget:self.slideMenuController action:@selector(toggleMenu) forControlEvents:UIControlEventTouchUpInside];
[a1 setImage:[UIImage imageNamed:@"menu-enable-bt.png"] forState:UIControlStateNormal];
UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 65.0,63.0) ];
[view addSubview:a1];
menuButton = [[UIBarButtonItem alloc] initWithCustomView:view];
rootViewController.navigationItem.leftBarButtonItem = menuButton;
我不知道怎么了试试这个
a1 = [UIButton buttonWithType:UIButtonTypeCustom];
[a1 setFrame:CGRectMake(0.0f, 0.0f, 30.0f, 30.0f)];
[a1 addTarget:self.slideMenuController action:@selector(toggleMenu) forControlEvents:UIControlEventTouchUpInside];
[a1 setImage:[UIImage imageNamed:@"menu-enable-bt.png"] forState:UIControlStateNormal];
UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 35.0,35.0) ];
[view addSubview:a1];
menuButton = [[UIBarButtonItem alloc] initWithCustomView:view];
rootViewController.navigationItem.leftBarButtonItem = menuButton;
UINavigationBar
高度为44,设置帧(0.0,0.0,65.0,63.0),更改帧高度以适应UINavigationBar
您是否尝试降低cDirectMake(0.0,0.0,65.0,63.0)中的高度?是的,您可能正在泄漏视图
和菜单按钮
也代替-
a1 = [UIButton buttonWithType:UIButtonTypeCustom];
[a1 setFrame:CGRectMake(0.0f, 0.0f, 65.0f, 63.0f)];
[a1 addTarget:self.slideMenuController action:@selector(toggleMenu) forControlEvents:UIControlEventTouchUpInside];
[a1 setImage:[UIImage imageNamed:@"menu-enable-bt.png"] forState:UIControlStateNormal];
UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 65.0,63.0) ];
[view addSubview:a1];
menuButton = [[UIBarButtonItem alloc] initWithCustomView:view];
您只需在CustomView:a1中提供menuButton=[[uibarbuttonim alloc]init代码>然后-
rootViewController.navigationItem.leftBarButtonItem = menuButton;
[menuButton release];
像这样试试
UIButton * a1 = [UIButton buttonWithType:UIButtonTypeCustom];
[a1 setFrame:CGRectMake(0.0f, 0.0f, 65.0f, 33.0f)];
[a1 addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
[a1 setImage:[UIImage imageNamed:@"sc.png"] forState:UIControlStateNormal];
UIBarButtonItem* menuButton = [[UIBarButtonItem alloc] initWithCustomView:a1];
self.navigationItem.leftBarButtonItem = menuButton;
你有没有试着降低CGRectMake(0.0,0.0,65.0,63.0)中的高度?
?我知道在这里这样说不合适,但我真的很喜欢它现在的样子:)让我知道有关这方面的任何问题?这样做了,但没有用。。问题仍然是一样的