CoreAnimation / CAGradientLayer
I need some help - how can I use objc_util to use the CAGradientLayer class.
I can't seem to figure out what Framework(s) I might need to load.
Using ObjcClass it can't seem to find CAGradientLayer.
Ideally I want to setup a function which can generate buttons and views with a gradient as a background.
Any help would be appreciated!
@reticulated, looks like it is in the QuartzCore framework.
Would be interesting to see your results.
Eureka (my error, colors need to be CGColors...)
from objc_util import * import ui v = ui.View() v.frame = (0,0,300,300) ov = ObjCInstance(v) layer=ov.layer() CAGradientLayer = ObjCClass('CAGradientLayer') grlayer = CAGradientLayer.layer() grlayer.frame=layer.bounds() grlayer.setColors_([ObjCClass('UIColor').blueColor().CGColor(),ObjCClass('UIColor').redColor().CGColor()]) layer.addSublayer_(grlayer) v.present('sheet')
If you prefer to be able to set r,g,b colors:
Hey thank you everyone.
I must have had a typo when I initially posted this - but it seems to work now.
Notes: I used ui.parse_color('blue').CGColor()
This works with RGBA, Hex and Named Colors.
Ill post the code when done, I am using this to create custom button styles, along with some custom styles for "checkbox" functionality (circles, squares, stars, etc)
Thanks again for your help!