iOS photo album does not have a back button

Recently, some models occasionally appear to call the album without a back button. The solution (write a button by yourself):

[_sourceVC presentViewController:picker animated:YES completion:^{
        UIViewController *vc = picker.viewControllers.lastObject;
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(0, 0, 35, 33);
        [btn setTitle:@"取消" forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:17];
        [btn addTarget:self action:@selector(cancleClick) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitleColor:[UIColor colorWithHexString:@"#287fec"] forState:UIControlStateNormal];//colorWithHexString自定义方法,请忽略
        vc.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    }];

The key point here is the color value #287fec, which is the blue color value of the original cancel button sucked out by the UI (Apple system buttons are all blue). It may be a bit inaccurate, but my scum can be seen with the naked eye. Does not come out.

Guess you like

Origin blog.csdn.net/qq_28285625/article/details/103785910