美文网首页
iOS 14使用PHPhotoLibrary弹窗图片选择页面搜索

iOS 14使用PHPhotoLibrary弹窗图片选择页面搜索

作者: 结局怎么写 | 来源:发表于2021-06-11 14:57 被阅读0次

iOS 14使用PHPhotoLibrary获取图片库数据,如果是受限访问时,即权限是PHAuthorizationStatusLimited,需要弹出权限选择的警告,当用户点击选择更多照片...时,使用下面的代码可调起重新选择照片的视图。但是该视图的搜索框可能是透明的。

    if (@available(iOS 14, *)) {
        [[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:self];
    }

此时需要设置[UISearchBar appearance]的背景色来解决。

    UIImage *bgImage = [UIImage qmui_imageWithColor:[UIColor whiteColor] size:CGSizeMake(PixelOne, PixelOne) cornerRadius:0];
    [[UISearchBar appearance] setBackgroundColor:UIColor.whiteColor];
    [[UISearchBar appearance] setBackgroundImage:bgImage];

相关文章

网友评论

      本文标题:iOS 14使用PHPhotoLibrary弹窗图片选择页面搜索

      本文链接:https://www.haomeiwen.com/subject/mtcveltx.html