标签:des blog http color os 2014
为相机制作闪光灯,在导航栏自定义了“闪光”图案,希望点击时变换图片,但是一直没有改变,原来是因为设置了Global Tint的颜色,所以系统会自动把图片的颜色改为Global Tint的颜色。
解决方案,设置图片时,添加:imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
源码:
- (void) setFlashOn:(BOOL)isOn { if (self.captureDevice.hasFlash) { UIImage* flashlIcon; [self.captureDevice lockForConfiguration:nil]; //you must lock before setting torch mode if (isOn) { NSLog(@"set flash on"); [self.captureDevice setFlashMode:AVCaptureFlashModeOn]; flashlIcon = [UIImage imageNamed:@"flash_on"]; } else{ NSLog(@"set flash off"); [self.captureDevice setFlashMode:AVCaptureFlashModeOff]; flashlIcon = [UIImage imageNamed:@"flash_off"]; } [self.captureDevice unlockForConfiguration]; [self.navigationItem.rightBarButtonItem setImage:[flashlIcon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; } else{ NSLog(@"Sorry, this device doesn't have flash."); } }
iOS 为导航栏自定义按钮图案Button Image 运行出来的颜色与原本颜色不一样 -解决方案,布布扣,bubuko.com
iOS 为导航栏自定义按钮图案Button Image 运行出来的颜色与原本颜色不一样 -解决方案
标签:des blog http color os 2014
原文地址:http://blog.csdn.net/willyang519/article/details/37566593