gpt4 book ai didi

iOS 7 : Adding modal ViewController with transparency : Custom Size

转载 作者:行者123 更新时间:2023-11-29 10:43:09 25 4
gpt4 key购买 nike

我想要做的是呈现一个来自底部并具有自定义大小的 viewController。无论我看起来做什么,要么看起来很糟糕(例如动画化,闪烁然后变得透明),要么全屏显示,要么全屏黑屏。我已经阅读了一些使用自定义委托(delegate)处理动画的解决方案,但必须有一种简单的方法。还有很多解决方案适用于 iOS 6 <

    HackViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"HackViewController"];
vc.delegate = self;
vc.modalPresentationStyle= UIModalPresentationCustom;
vc.view.frame = CGRectMake(0, 0, 800, 400);
vc.credits = CREDIT_PER_LEVEL * building.buildingLevels;
vc.view.backgroundColor = [UIColor clearColor];

[self presentViewController:vc animated:YES completion:^{
vc.view.backgroundColor = [UIColor clearColor];
}];

最佳答案

如果您想在第一个 viewController(例如 VC1)上添加 viewController(例如 VC2)作为模式,那么在 VC1 中,当您呈现 VC2 时,

[self presentViewController:VC2 animated:YES completion:nil];

VC2 viewDidLoad

[self.view setBackgroundColor:[UIColor colorWithRed:211.0/255.0 green:211.0/255.0 blue:211.0/255.0 alpha:0.8]];

并且,在 AppDelegateapplication didFinishLaunchingWithOptions:

[[self.window rootViewController] setModalPresentationStyle:UIModalPresentationCurrentContext];

您可以在VC2中创建其他 View ,如imageViewlabel

关于iOS 7 : Adding modal ViewController with transparency : Custom Size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23471529/

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