gpt4 book ai didi

ios - 使自定义事件指示器 View 的 UIView 半透明

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:58 24 4
gpt4 key购买 nike

我已经为我的 iOS 应用程序实现了一个自定义事件指示器 View ,它运行得很流畅。要求是在自定义事件指示器动画时将 superview 的 alpha 设置为 50%(或使其半透明),并在自定义事件指示器停止时将其设置为正常。我正在使用以下类方法添加要查看的自定义事件指示器。

+ (CustomActivityIndicatorView*)addCustomActivityIndicatorToView:(UIView *)view
{
CustomActivityIndicatorView *customActivityIndicatorView = [[CustomActivityIndicatorView alloc]init];
customActivityIndicatorView.hidesWhenStopsAnimating = NO;
[customActivityIndicatorView setFrame:CGRectMake(view.bounds.size.width/2-(customActivityIndicatorView.frame.size.width/2), view.bounds.size.height/2-(customActivityIndicatorView.frame.size.height/2), customActivityIndicatorView.frame.size.width, customActivityIndicatorView.frame.size.height)];
[view addSubview:customActivityIndicatorView];
[customActivityIndicatorView startAnimating];

return customActivityIndicatorView;
}

问题是,当我设置 [view setAlpha:0.5] 时,它会将 alpha 设置为所有 subview ,包括自定义事件指示器。我想淡化 super View 而不是自定义事件指示器。

阅读所有这些链接;

https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

UIView group opacity in single view heirachy

iOS controlling UIView alpha behaviour for subviews

还尝试设置 layer.shouldRasterize 和组不透明度的 plist 键,但没有任何帮助。请帮忙!

最佳答案

您可以在父 View 和指示器之间的顶部放置一个半白色或半黑色覆盖层,而不是让整个父 View 褪色。这将在视觉上起到作用。

叠加层将具有 alpha = 1.backgroundColor = [UIColor colorWithWhite:1。 alpha:.5]

关于ios - 使自定义事件指示器 View 的 UIView 半透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24133985/

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