Alex Coplan
Alex Coplan

Reputation: 13371

Three20 TTStyle Drop-shadow

I'm trying to create a fancy-looking header to a view. I'm using a TTView with styling applied, but my problem is I want the drop shadow to just drop below the image, and not to the sides. I want the sides hard up against the screen edges.

Here is what it looks like at the moment:

enter image description here

How can I make it so the sides are hard up against the edge of the screen?

Here is my code for the styling:

UIColor* black = RGBCOLOR(158, 163, 172);
UIColor* blue = RGBCOLOR(191, 197, 208);
TTStyle *style = 
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.5) blur:5 offset:CGSizeMake(0, 2) next:
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(255, 255, 255)
                                    color2:RGBCOLOR(216, 221, 231) next:
[TTFourBorderStyle styleWithTop:blue right:black bottom:black left:blue width:1 next:nil]]];

headerView.style = style;

I would appreciate any help with this issue as I've never used three20 before now.

Upvotes: 1

Views: 372

Answers (2)

Alex Coplan
Alex Coplan

Reputation: 13371

I figured it out by experimentation in the end - if you use a negative UIEdgeMask on the sides before the drop-shadow in the style chain, it pushes the main view out to the edges.

TTStyle *style = 
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, -5, 0, -5) next: 
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.5) blur:5 offset:CGSizeMake(0, 2) next:
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(255, 255, 255)
                                    color2:RGBCOLOR(216, 221, 231) next:
[TTFourBorderStyle styleWithBottom:black width:1 next:nil]]]];

Upvotes: 1

Nimit Parekh
Nimit Parekh

Reputation: 16864

self.btn1.layer.shadowOffset = CGSizeMake(10, 10); //set the the value for the shade size when the negative that goes to oposite side of current.
    self.btn1.layer.shadowOpacity = 0.9;
    self.btn1.layer.shouldRasterize = YES;
    self.btn1.layer.shadowColor=[[UIColor grayColor]CGColor];

May this code is helping to you

Upvotes: 0

Related Questions