gpt4 book ai didi

iOS 透明 View Controller

转载 作者:行者123 更新时间:2023-11-28 19:15:12 25 4
gpt4 key购买 nike

我正在尝试创建一个透明的模式 ViewController,它覆盖当前的 ViewController。我将 backgroundcolor 设置为 clearcolor 但背景是黑色的,因为另一个 View Controller 没有显示在新 View Controller 后面。我想要一个像 UIAlertView 这样的叠加层。

我谷歌了很多,我找到的唯一解决方案是添加一个 subview 。我正在使用 iOS5。

最佳答案

将背景颜色设置为清除您呈现模型 View 后,将背景设置为清除然后再呈现将不起作用。

如果你想呈现像 UIAlertView 这样的 View ,使用这个-

CAKeyframeAnimation *animation = [CAKeyframeAnimation
animationWithKeyPath:@"transform"];

CATransform3D scale1 = CATransform3DMakeScale(0.5, 0.5, 1);
CATransform3D scale2 = CATransform3DMakeScale(1.2, 1.2, 1);
CATransform3D scale3 = CATransform3DMakeScale(0.9, 0.9, 1);
CATransform3D scale4 = CATransform3DMakeScale(1.0, 1.0, 1);

NSArray *frameValues = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:scale1],
[NSValue valueWithCATransform3D:scale2],
[NSValue valueWithCATransform3D:scale3],
[NSValue valueWithCATransform3D:scale4],
nil];
[animation setValues:frameValues];//Courtesy zoul.fleuron.cz

NSArray *frameTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.9],
[NSNumber numberWithFloat:1.0],
nil];
[animation setKeyTimes:frameTimes];

animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.duration = .2;
[self.backColor SETCOLOUR HERE];
[self.layer addAnimation:animation forKey:@"uialertViewPopUP"];

您可以使用上面给出的代码覆盖 willMoveToSuperView 方法。

关于iOS 透明 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12562153/

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