gpt4 book ai didi

objective-c - UIView 在 iOS 设备上不透明,但在模拟器上是透明的

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:23 26 4
gpt4 key购买 nike

有一个我想透明化的 View ,它可以在模拟器上运行,但由于某种原因不能在我的设备上运行。我不知道为什么会这样。我的代码如下所示:

- (void)viewDidLoad

[...]
UIView *transparentBackgroundView = [[UIView alloc] initWithFrame:self.view.frame];

// Doesn't work on my device.
transparentFlipBackgroundView.backgroundColor = [UIColor clearColor];

// I have also tried.
// transparentFlipBackgroundView.alpha = 0;
// transparentFlipBackgroundView.opaque = YES
// transparentFlipBackgroundView.layer.backgroundColor = [UIColor clearColor].CGColor;

// I later add the view to an array...
self.pageViews = [[NSMutableArray alloc] initWithObjects:transparentFlipBackgroundView, lastPage, nil];
[...]
}

知道为什么会发生这种情况吗?我应该如何使 UIView 透明?

最佳答案

努力改变

transparentFlipBackgroundView.backgroundColor = [UIColor clearColor];

transparentFlipBackgroundView.backgroundColor = 
[UIColor colorWithRed:0 green:0 blue:0 alpha:0];

关于objective-c - UIView 在 iOS 设备上不透明,但在模拟器上是透明的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11886520/

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