UIImageView的缓存问题

    xiaoxiao2021-03-25  88

    UIImageView *imageView = [[UIImageView alloc] init];

    imageView.image = [UIImage imageNamed:@"avatar_vip"];

    //    NSString *file = [[NSBundle mainBundle] pathForResource:@"avatar_vip@2x" ofType:@"png"];

    //    imageView.image = [UIImage imageWithContentsOfFile:file];

    imageView.frame = CGRectMake(10, 50, 34, 34);

    [self.view addSubview:imageView];

    // 这个方法加载的图片不会有缓存,适合用来加载大图片、一次性的图片(使用频率比较低)

    //    [UIImage imageWithContentsOfFile:<#(NSString *)#>];

    // 这个方法加载的图片会有缓存,适合用来加载小图片、使用频率比较高的图片

    //    [UIImage imageNamed:@"searchbar_textfield_background"];

    // 建议:1.小图片可以放在Images.xcassets中;2.大图片建议放在Supporting Files

    }

    转载请注明原文地址: https://ju.6miu.com/read-19720.html

    最新回复(0)