为什么图标info.png保持蓝色并且没有附带该图像的原始颜色?我使用以下代码:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"info.png"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(info:)];
Run Code Online (Sandbox Code Playgroud) 有没有办法从 UIImage 获取以 KB 为单位的文件大小,而不从 didFinishPickingMediaWithInfo 获取该图像?所呈现的图像来自相册。
我尝试了以下代码,但这给出了以下结果:图像大小(KB):0.000000
- (void)setImage:(UIImage *)image
{
_image = image;
self.imageView.image = image;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setupView];
self.backgroundColor = [UIColor whiteColor];
panGestureRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(beingDragged:)];
[self addGestureRecognizer:panGestureRecognizer];
// prepare image view
self.imageView = [[UIImageView alloc]initWithFrame:self.bounds];
self.imageView.clipsToBounds = YES;
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:self.imageView];
NSData *imgData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((_image), 0.5)];
int imageSize = imgData.length;
NSLog(@"size of image in KB: %f ", imageSize/1024.0);
overlayView = …Run Code Online (Sandbox Code Playgroud)