用不透明的UIButton或UIImage呈现透明的UIView



我试图在使用presentViewController时制作透明的UIView。问题是UIButtonUIImageView总是透明的,我怎么能使它们不透明呢?

targetViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"newViewController"];
targetViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:targetViewController animated:YES completion:nil];

结果:https://i.stack.imgur.com/YJjBv.png

我希望UIButtonUIImageView是不透明的。我该怎么做呢?

不使用UIView的alpha,使用clear backgroundColor

targetViewController.view.backgroundColor = [UIColor clearColor];

最新更新