方向的UIView阴影问题 [英] UIView shadow issue with orientation
问题描述
我有UiTableView within UiView
.我想将corner radius & shadow
设置为UIView
.
我正在使用此代码来提供shadow with corner
及其正常工作.
I have UiTableView within UiView
. I want to set corner radius & shadow
to UIView
.
I am using this code to give shadow with corner
and its working fine.
myView.backgroundColor = [UIColor clearColor];
[myView.layer setCornerRadius:10.0f];
[myView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[myView.layer setBorderWidth:1.0f];
[myView.layer setShadowColor:[UIColor blackColor].CGColor];
[myView.layer setShadowOpacity:0.8];
[myView.layer setShadowRadius:3.0];
[myView.layer setShadowOffset:CGSizeMake(2.0, 2.0)];
// below line is for smooth scrolling
[myView.layer setShadowPath:[UIBezierPath bezierPathWithRect:myView.bounds].CGPath];`
Portrait mode
一切正常.我的应用程序同时支持Orientation
和Autoresizing property
.当我更改方向Shadow is displaying according to frame of Portrait mode
时.如何同时管理两个方向.
everything working fine with Portrait mode
. My app is supported both Orientation
and we are using Autoresizing property
fot that. When i change the orientation Shadow is displaying according to frame of Portrait mode
. How can this manage for both Orientation.
任何想法如何根据Orientation OR bound更改setShadowPath
吗?
Any idea how to change setShadowPath
according to Orientation OR bound ?
推荐答案
我找到了自己的解决方案.我创建了一个方法- (void) viewWithEffects: (UIView*) myView {// copy the shadow code from the question}
.现在,我将此方法称为- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{}
.
I have a found the solution of my own. i have a created one method - (void) viewWithEffects: (UIView*) myView {// copy the shadow code from the question}
. Now i called this method to - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{}
.
因此,当方向改变didRotateFromInterfaceOrientation
调用时,它将给出Corner with Shadow effects.
阴影,该阴影将根据Autoresize
设置为您的视图.如果两个方向都不支持您的应用,则无需执行此操作.只需在viewdidload or viewwillAppear
上调用一个即可.我希望这会有所帮助.
So when orientation change didRotateFromInterfaceOrientation
call and it will give the Corner with Shadow effects.
Shadow will set to your view according to Autoresize
your view. if your app not supported for both orientation than dont need to do this. Just call one on viewdidload or viewwillAppear
. i hope it will help .
这篇关于方向的UIView阴影问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!