Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIView在iOS设备上不透明,但在模拟器上透明_Objective C_Ios_Cocoa Touch_Uiview_Transparency - Fatal编程技术网

Objective c UIView在iOS设备上不透明,但在模拟器上透明

Objective c UIView在iOS设备上不透明,但在模拟器上透明,objective-c,ios,cocoa-touch,uiview,transparency,Objective C,Ios,Cocoa Touch,Uiview,Transparency,有一个我想要透明的视图,它可以在模拟器上工作,但由于某些原因不能在我的设备上工作。我不知道为什么会这样。我的代码如下所示: - (void)viewDidLoad [...] UIView *transparentBackgroundView = [[UIView alloc] initWithFrame:self.view.frame]; // Doesn't work on my device. transparentFlipBackgroundView

有一个我想要透明的视图,它可以在模拟器上工作,但由于某些原因不能在我的设备上工作。我不知道为什么会这样。我的代码如下所示:

- (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透明?

你有其他设备可以试用吗?如果它能在模拟器上工作,那么它肯定也能在你的设备上工作吗?如果您愿意,我不介意在我的一台设备上试用。

这是一个相当粗糙的解决方案,但我通过使用CGRectZero创建视图来修复它。

尝试更改

transparentFlipBackgroundView.backgroundColor = [UIColor clearColor];


我在XCode5和iOS7SDK上遇到了这个问题。我发现我在辅助功能设置(设置/常规/辅助功能)下打开了“增加对比度”。这导致导航栏的透明度低于关闭此设置时的透明度

把它关掉,现在我可以看到栅栏后面的透明了。它仍然没有模拟器那么多,但现在好多了

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