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

2021-06-11  本文已影响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];
上一篇 下一篇

猜你喜欢

热点阅读