Iphone 按钮图像失真
我正在尝试在导航控制器栏上创建UIButton。然而,当我尝试这样做时,我的图像被扭曲了 以下是我正在使用的代码:Iphone 按钮图像失真,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我正在尝试在导航控制器栏上创建UIButton。然而,当我尝试这样做时,我的图像被扭曲了 以下是我正在使用的代码: UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom]; [sampleButton setTitle:@"Title" forState:UIControlStateNormal]; [sampleButton setBackgroundImage:[[UIImage imageNamed:@"b
UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[sampleButton setTitle:@"Title" forState:UIControlStateNormal];
[sampleButton setBackgroundImage:[[UIImage imageNamed:@"but.png"] [sampleButton addTarget:self action:@selector(pushNav)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:sampleButton];
任何帮助都将不胜感激,我快疯了,哈哈。谢谢没关系,我终于明白了。英雄联盟根据是否将按钮添加为项目,您必须使用不同的CGRectMake
[sampleButton setFrame:CGRectMake(0,32,90,32)];
90将图像拉伸到所需的长度
确保不要将sampleButton作为一项添加到导航栏,以使上述代码无法正常工作 如果你自己回答,你应该为将来的读者提供答案。