gpt4 book ai didi

ios - 自定义覆盖不透明

转载 作者:行者123 更新时间:2023-11-29 02:56:42 25 4
gpt4 key购买 nike

我正在做一些相当简单的事情。我创建了一个简单的 NIB,其中只有一个分段控件。主要用于测试目的。我正在尝试使用此 NIB 加载到 UIImagePickerController 覆盖层中。但加载后,覆盖层不透明。仅显示白色背景和相机 View 顶部中心的按钮。我尝试了overlay.opaque = NO,但没有成功。

这是我的代码:

@property (nonatomic) IBOutlet UIView *viewTest;
@property (nonatomic, weak) IBOutlet UISegmentedControl *switchButtonTest;

后来,我有了这个方法(主要来自苹果的APLViewController示例

- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;

if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
imagePickerController.showsCameraControls = NO;

[[NSBundle mainBundle] loadNibNamed:@"ViewTest" owner:self options:nil];
self.viewTest.frame = imagePickerController.cameraOverlayView.frame;
imagePickerController.cameraOverlayView = self.viewTest;
self.viewTest = nil;
}

self.imagePickerController = imagePickerController;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}

最佳答案

要摆脱白色背景 View ,请将其颜色更改为 clearColor(或者一开始就不要使用它)。要使分段控件不那么不透明,请将其 alpha 设置为 0.2

关于ios - 自定义覆盖不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23795726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com