小编Jan*_*Jan的帖子

UIBarButtonItem图像保持蓝色而不是图像的原始颜色?

为什么图标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)

xcode objective-c uibarbuttonitem

26
推荐指数
6
解决办法
2万
查看次数

如何获取 UIImage 的大小(以 KB 为单位)?

有没有办法从 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)

xcode objective-c uiimage nsdata ios

3
推荐指数
1
解决办法
5223
查看次数

标签 统计

objective-c ×2

xcode ×2

ios ×1

nsdata ×1

uibarbuttonitem ×1

uiimage ×1