last day (14 days later) » 

10:25 AM
0
A: How to create Box-Shadow in IOS

holexI've got that on my screen: with this code snippet: [_backgroundBoxWithShadow setBackgroundColor:[UIColor whiteColor]]; [_backgroundBoxWithShadow.layer setOpacity:0.4]; [_backgroundBoxWithShadow.layer setShadowColor:[[UIColor blackColor] CGColor]]; [_backgroundBoxWithShadow.layer setShadowOf...

 
S.P
its not working this one not showing the shadow
 
as you can see on my screenshot, that is the result I've got with those layer's settings.
 
S.P
i see but not working for me
imag.backgroundColor=[UIColor whiteColor]; [imag.layer setOpacity:0.4]; [imag.layer setShadowColor:[[UIColor blackColor] CGColor]]; [imag.layer setShadowOffset:CGSizeMake(0.0, 0.0)]; [imag.layer setShadowRadius:8.0];
 
which shadow do you miss?
 
S.P
_backgroundBoxWithShadow shadow i am missing i used the above code
any thing i am missing
 
10:25 AM
okay, I will take a look on it whether there is another layer's setting is necessary, but I have not set anything else, I guess... just double checking.
I check my code again, bear with me.
 
S.P
10:37 AM
@ho
@holex it showing like this
@h
@holex r u there
@holex i am using following code UIImageView *imag = (UIImageView*)[self.view viewWithTag:1];
imag = [[UIImageView alloc] initWithFrame:CGRectMake((screenWidth/100)*12, (screenHeight/100)*10, (screenWidth/100)*75, (screenHeight/100)*61)];

[imag setBackgroundColor:[UIColor whiteColor]];
[imag.layer setOpacity:0.4];
[imag.layer setShadowOpacity:1.0];
[imag.layer setShadowColor:[[UIColor blackColor] CGColor]];
[imag.layer setShadowOffset:CGSizeMake(0.0, 0.0)];
[imag.layer setShadowRadius:8.0];
 
11:10 AM
okay. why that is ugly on your screen is simple.
you have set the imag.alpha property somewhere else, however it must be 1.0, and the background color must be [UIColor white]. you cannot set any alpha for the background colour either.
that causes your problem here.
check your code please, and remove everything else which changes your alpha value, and set the background colour directly to solid white with alpha 1.0.
 
S.P
ok i check
 
my code does not changes those values for reason, because that would affect the shadow generation, and the result is the same as on your screen.
if I change the background colour like this: `[imag setBackgroundColor:[UIColor colorWithWhite:1.0 alpha:0.5]];` I will got the same ugly result on the screen.
`
 
S.P
no i didnt set any alpha
 
in the interface builder? have you change the alpha in the interface builder perhaphs?
or I will got the same ugly result as you shared with me, if I set the alpha sometjing else than 1.0 for the imag.
 
S.P
no alpha is not there
and i create alpha as 1 but no use
 
11:18 AM
so that is the two possible reasons why you get this ugly grayed result. otherwise it must be as on my screeshots.
I'm not seeing your code, so I cannot tell what is happening there, but those are the reasons.
and you must set the alpha 1.0, and must not change anywhere else later.
 
S.P
i am using
UIImageView *imag = (UIImageView*)[self.view viewWithTag:1];
imag = [[UIImageView alloc] initWithFrame:CGRectMake((screenWidth/100)*12, (screenHeight/100)*10, (screenWidth/100)*75, (screenHeight/100)*61)];
[imag setBackgroundColor:[UIColor whiteColor]];
[imag.layer setOpacity:0.4];
[imag.layer setShadowOpacity:1.0];
[imag.layer setShadowColor:[[UIColor blackColor] CGColor]];
[imag.layer setShadowOffset:CGSizeMake(0.0, 0.0)];
[imag.layer setShadowRadius:8.0];
[imag setClipsToBounds:FALSE];
[imag.layer setMasksToBounds:FALSE];
and my version is 6.1
 
okay, byt that snippet works well. there is something else what you missed in your code. this shadow effect is the same since iOS5.1, so is has to be the same on any newer iOS versions, including iOS6.1.
 
S.P
holex 7.1 it is working fine now only i check but ios 6 not working
 
I'm just cheking on iOS6....
 
S.P
ok
did u checked
 
11:30 AM
no, not yet... my iPad with iOS6 deadly drained... I need to charge it it fist, but I'm looking for a changer... I'm on it.
meanwhile... may I ask you why you force iOS6? usually a project should support the last two major version (Apple's standard support policy), and the iOS8 is coming out in a few weeks time, it may be worth to update the target. have you considered about such thing yet?
 
S.P
for me i need to support from 3.0 onwards
 
that is a bit pointless request fro your client, regarding the Xcode5 does not even support to compile any project for lower version than iOS6. and if you are using older compiler, you won't be able to submit your app to AppStore. nevertheless, the dispersion of used version of IOS is something like like: current version 90%, last major version 5%, then 3%, then the rest iOS version are in the rest of 2%. (not proper statistics, but it shows the ratio).
so, you need to support iOS3, which runs literally on the 1st generation of iPhone and iPod Touch (2007).
sorry for saying this, but makes no too much sense. :)
 
S.P
11:47 AM
ya actually we are using enterprise app release,not the appstore release
 
oh I see... and which compiler are you using?
 
S.P
x code 4.6
and also having xcode 5.1.1
but now i need solution for ios 6
 
okay, will see soon what is wrong with iOS6. it is not very common iOS version nowadays... It took time to find even a device which already has it, but it is still not up yet. never mind. I can check somehow else that code on iOS6.
 
12:04 PM
I think I'm close to see the result on iOS6.
I'm seeing what is going on here... I will update my answer soon. it is lunchtime. :)
I'm going to leave you a note when my answer is updated.
 
S.P
ok thankyou
 

last day (14 days later) »