我在UINavigationBar rightBarButtonItem中设置了pdf矢量图像,但它仍然显示得太小。
如何在UINavigationBar中显示全尺寸矢量图像?
我试过以下代码: - 第一种方式: -
UIBarButtonItem *barbutton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@“imgRightArrow”] style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.rightBarButtonItem = barbutton;
第二种方式: -
UIImage *image = [UIImage imageNamed:@“imgRightArrow”]
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:image forState:UIControlStateNormal];
[button.imageView setContentMode:UIViewContentModeScaleToFill];
button.frame = CGRectMake(0, 0, 35, 35);
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
我所做的是将图标保存三次,25px,50px,75px,并将这三个一起添加到资源(x1,x2,x3)中,这样你就不必在代码中设置图标的大小。