更改子视图的alpha而不更改父视图的alpha [英] change alpha of a child view without changing alpha of parent view

查看:115
本文介绍了更改子视图的alpha而不更改父视图的alpha的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个uiviews 1个孩子和1个父父视图在点击按钮时有alpha .30我想将子视图的alpha更改为1.0或0.0如果是,那么这是可能的。



请赐教。



预付Thanx
:)

解决方案

尝试使用
UIView 的alpha属性,此值仅影响当前视图,不影响任何它的嵌入式子视图。



UIView中读取 alpha 的Apple文档



http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html



'p>更新:低于



尝试

  [parentView setBackgroundColor:[[的UIColor clearColor] colorWithAlphaComponent:0.5]]; 
[childView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:1.0]];


I have two uiviews 1 child and 1 parent parent view has alpha .30 on click of button I want to change alpha of child view to 1.0 or 0.0 is this possible if yes then how.

Please enlighten me on this.

Thanx in advance :)

解决方案

Try with the alpha property of UIView and This value affects only the current view and does not affect any of its embedded subviews.

Read the Apple Documentation for alpha in UIView.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

Updated:Try with below

[parentView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.5]];
[childView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:1.0]];

这篇关于更改子视图的alpha而不更改父视图的alpha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆