3

透明にしたいビューがあります。シミュレーターでは機能しますが、何らかの理由でデバイスでは機能しません。なぜこれが起こるのか分かりません。私のコードは次のようになります:

- (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を透過的にするにはどうすればよいですか?

4

4 に答える 4

2

変更してみる

transparentFlipBackgroundView.backgroundColor = [UIColor clearColor];

transparentFlipBackgroundView.backgroundColor = 
                                      [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
于 2012-08-10T11:16:04.647 に答える
1

試用できる別のデバイスはありますか?シミュレーターで動作する場合は、デバイスでも動作するはずですか? よろしければ、私のデバイスで試してみても構いません。

于 2012-08-09T15:59:26.710 に答える
0

かなりハッキーな解決策ですが、CGRectZeroでビューを作成して修正しました。

于 2012-08-10T11:13:12.377 に答える