privateson
asked on
How to put gradient style table cell in a table?
Hey, I am making a custom table cell right now but my custom cell is just white cell with some buttons and labels in background color which looks not that great.
Is there a way to render the background color so that the cell has some vertical gradient effect?
For example, on top of the cell it looks white and as it gets closer to center of the cell, it gets darker.
But as it gets closer to the bottom of the cell, it gets whiter again.
A great example would be this free app called "friendsaroundme".
Another thing is that I don't want to use custom image to do it (i.e make the cell.backgroundcolor = [uicolor colorwithpatternimage:some thingsomet hing.png.. ... ) because it's not that flexible.
So is there anyway to render the gradient style programatically?
Is there a way to render the background color so that the cell has some vertical gradient effect?
For example, on top of the cell it looks white and as it gets closer to center of the cell, it gets darker.
But as it gets closer to the bottom of the cell, it gets whiter again.
A great example would be this free app called "friendsaroundme".
Another thing is that I don't want to use custom image to do it (i.e make the cell.backgroundcolor = [uicolor colorwithpatternimage:some
So is there anyway to render the gradient style programatically?
You can draw whatever you want in the drawRect method.
Mac OS X Reference Library. Advanced Drawing Techniques
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/AdvancedDrawing.html
Pay attention on NSGradient and the example for it in this link.
Sorry, only now I see that the question can be about iPhone SDK. I do not know if NSGradient is there. But drawRect works always. :) For a test, for a beginning, you can try these examples from here:
http://en.wikibooks.org/wiki/Programming_Mac_OS_X_with_Cocoa_for_beginners/Graphics_-_Drawing_with_Quartz
I did find the gradient for iPhone SDK here:
http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone
The last code in that thread contains the code you need for iPhone - manually created gradient fill for the rectangle.
And here is iPhone OS Reference Library with full explanation and many samples:
Gradients
http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_shadings/dq_shadings.html#//apple_ref/doc/uid/TP30001066-CH207-TPXREF101
Mac OS X Reference Library. Advanced Drawing Techniques
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/AdvancedDrawing.html
Pay attention on NSGradient and the example for it in this link.
Sorry, only now I see that the question can be about iPhone SDK. I do not know if NSGradient is there. But drawRect works always. :) For a test, for a beginning, you can try these examples from here:
http://en.wikibooks.org/wiki/Programming_Mac_OS_X_with_Cocoa_for_beginners/Graphics_-_Drawing_with_Quartz
I did find the gradient for iPhone SDK here:
http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone
The last code in that thread contains the code you need for iPhone - manually created gradient fill for the rectangle.
And here is iPhone OS Reference Library with full explanation and many samples:
Gradients
http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_shadings/dq_shadings.html#//apple_ref/doc/uid/TP30001066-CH207-TPXREF101
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://slayeroffice.com/code/gradient/