Core Graphics Tutorial: Lines, Rectangles, and Gradients

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: Lines, Rectangles, and Gradients

Postby rwenderlich » Mon Apr 15, 2013 11:00 am

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

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby swe19 » Mon Apr 15, 2013 7:10 pm

Thanks for this update.
swe19
Hacker
 
Posts: 16
Joined: Wed Nov 02, 2011 1:31 am
Has thanked: 0 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby northy179 » Mon Apr 15, 2013 10:18 pm

Great update, this would have to be the tutorial I most wanted to see updated.
Check out my apps, services and tutorials here: http://northysoftware.com
Learning Swift? Kick start the flow of knowledge by subscribing to the Swift Coder weekly newsletter: http://swift-coder.info
User avatar
northy179
iOS Tutorial Team Member
 
Posts: 948
Joined: Sun Jun 10, 2012 11:19 pm
Location: Australia
Has thanked: 19 times
Been thanked: 177 times

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby quinrado » Mon Apr 15, 2013 10:28 pm

The link at the end of the article is broken (the link to part II of the tutorial)
quinrado
n00b
 
Posts: 1
Joined: Mon Apr 15, 2013 10:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby TLewis » Tue Apr 16, 2013 3:37 am

Just a quick question, why not just create a custom class for the tableView cell and override drawRect: within the custom cell class? It seems like that might make more sense than using a custom UIView, and heck, when you create a subclass of UITableViewCell, it places a commented out drawRect: method in the .m file for you.

Just trying to clear up why you chose to use a UIView and set the background view of the cell, rather than draw on the cell itself.
TLewis
Hacker
 
Posts: 41
Joined: Sun Feb 24, 2013 8:03 pm
Has thanked: 0 time
Been thanked: 9 times

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby TLewis » Wed Apr 17, 2013 3:15 am

Also, an easy way to set this up would be to use UIAppearance. You would make a subclass of UITableViewCell like normal, and then in the .h file do this:

Code: Select all
- (void)setBackgroundView:(UIView *)backgroundView UI_APPEARANCE_SELECTOR;


and then in the .m do this:

Code: Select all
- (void)setBackgroundView:(UIView *)backgroundView {
    [super setBackgroundView:backgroundView];
}


And finally, in your app delegate just do this:

Code: Select all
[[CustomCellClass appearance]setBackgroundView:[[CustomCellBackground alloc]init]];


and then bam! You have your custom background set just like that. You can also do the same thing for the selectedBackgroundView, just make sure you put the UI_APPEARANCE_SELECTOR after the method definition.
TLewis
Hacker
 
Posts: 41
Joined: Sun Feb 24, 2013 8:03 pm
Has thanked: 0 time
Been thanked: 9 times

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby appDev » Tue Apr 30, 2013 4:47 am

I am applying the gradient to the UITableView cell. My cell has dynamic height. If my cell's height is large , it shows gradient 2 times for single cell. Here is my code & screenshot http://stackoverflow.com/questions/16279589/add-gradient-to-table-cell-with-dynamic-height-ios-6 of how it looks like. Can you tell me whats going wrong here ?
Thanks in advance.
appDev
Hacker
 
Posts: 12
Joined: Mon Jun 11, 2012 11:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: Core Graphics Tutorial: Lines, Rectangles, and Gradients

Postby Shai » Sun May 19, 2013 9:52 am

In the prototype cells' Attributes Inspector the background is set to "No Color". However, in my case the default was set to some white-ish color and I couldn't change it to "No Color". I have no idea why. I worked around the problem by selecting "other" and changing the opacity to 0.
Shai
n00b
 
Posts: 2
Joined: Sun May 19, 2013 9:41 am
Has thanked: 1 time
Been thanked: 0 time

Postby manheman » Fri Nov 29, 2013 3:21 pm

Hello,
I begin learning IOS and i want to create a image with areas event gesture. Is it possible to add gesture event in drawing area ? (sorry for my english... ;-)
manheman
Baby Hacker
 
Posts: 8
Joined: Fri Nov 29, 2013 1:01 am
Has thanked: 1 time
Been thanked: 0 time

Postby DanMoore24 » Fri Jan 10, 2014 8:38 pm

The final stroke drawn at the end of this tutorial doesn't work on iOS 7 (iPad).
DanMoore24
n00b
 
Posts: 2
Joined: Mon Jan 06, 2014 6:29 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: Bing [Bot] and 6 guests