Core Graphics Tutorial: Shadows and Gloss

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Core Graphics Tutorial: Shadows and Gloss

Postby rwenderlich » Tue Apr 16, 2013 11:00 am

This is the official thread to discuss the following blog post: Core Graphics Tutorial: Shadows and Gloss
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2058
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 293 times

Re: Core Graphics Tutorial: Shadows and Gloss

Postby nerry9 » Sat Apr 20, 2013 1:47 pm

Hi ,

I found code crashing while setting light and dark colour.
ex.

Code: Select all
CGContextSetFillColorWithColor(context, self.lightColor.CGColor);


For which I changed the autorelease light colour initialisation to a allocated variable.

Code: Select all
-(id) init{
    self=[super init];
    if(self){
        self.backgroundColor = [UIColor clearColor];
        self.opaque = NO;
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.opaque = NO;
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        _titleLabel.shadowOffset = CGSizeMake(0, -1);
        [self addSubview:_titleLabel];
       _lightColor = [[UIColor alloc] initWithRed:105.0f/255.0f green:179.0f/255.0f blue:216.0f/255.0f alpha:1.0];[list=][/list]
          _darkColor = [[UIColor alloc] initWithRed:21.0/255.0 green:92.0/255.0 blue:136.0/255.0 alpha:1.0];
    }
    return self;
}


Can you explain bit on blur value while setting shadow colour,I found in the documents that there is no range defined for it.
nerry9
Hacker
 
Posts: 10
Joined: Sat Sep 22, 2012 7:31 am
Has thanked: 1 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Shadows and Gloss

Postby gerry1218 » Fri Apr 26, 2013 1:21 pm

Hi,
how to zoom the simulator?
gerry1218
n00b
 
Posts: 1
Joined: Fri Apr 26, 2013 1:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Shadows and Gloss

Postby bassplayinMacFiend » Wed May 01, 2013 11:09 pm

nerry9 wrote:Hi ,

I found code crashing while setting light and dark colour.
ex.

Code: Select all
CGContextSetFillColorWithColor(context, self.lightColor.CGColor);


Change init to initWithFrame: and the original code will work correctly. :)

Code: Select all
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
                     // enter initialization code here
         }
   return self;
}


I don't have an answer for your second question.
bassplayinMacFiend
Hacker
 
Posts: 11
Joined: Fri Jan 06, 2012 1:18 am
Has thanked: 2 times
Been thanked: 1 time


Return to Official Tutorials

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests