ios - How do I create a UIView subclass with a transparent gradient background? -
I want to create a custom Here is an example image: Paint the orange box under my transparent gradient view is a I am But it does not support transparency, like when I add that code from How do I do this in CSS: But again, I do not know how to make this custom I will not be disturbed with core graphics, so I will use Override To redefine the Set color and other attributes. UIView which has a transparent gradient background to make the text more This custom view appears on the rear view.
UIView . Then I will put text at the top of the transparent shield view and because of its darkness, the text will appear more, but you can see some orange box behind it.
UIView .
- (zero) draw in my custom
UIView 's
drawRect : (CGRTact) shortcut {CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB (); CGContextRef Reference = UIGraphicsGetCurrentContext (); NSArray * gradientColors = @ [[id] [UIColor colorWithWhite: 0.0 alpha: 0.0] .Color, (id) [UIColor colorWithWhite: 0.0 alpha: 0.55] .CGColor, (id) [UIColor colorWithite: 0.0 alpha: 0.7]]; CGFloat Gradient Lesses [] = {0, 0.77, 1}; CGGradientRef Slope = CGGradientCreateWithColors (Color space, (__Bridge CFArrayRef) Gradient Colors, Gradient Lacs); CGPoint StartPoint = CGPEXMAC (CGRactGetMIDX (RECT), CGRactGatmini (RECT)); CGPoint Endpoint = CGPXMake (CGRactGetMIDX (RECT), CGRactGetMXY (Rect)); CGContextDrawLinearGradient (Reference, Slope, Start Page, End Page, 0); CGGradientRelease (Slope); }
UIView to
self.view Opaque black
Background image: Linear-gradient (-180 degrees, RGBA (0,0,0,0.00.00) 0% , RGBA (0,0,0,0,5,5) 23%, RGBA (0,0,0,0.70.70) 100%);
UIView subclass.
CAGradientLayer .
+ + + in your class
+ (class) layer class {return [CAGRD and LEA class]; }
layer property in the interface to use this class.
@property (nonatomic, read-only, retaining) CAGradientLayer * Layer;
self.layer.colors = gradientColors; Self.layer.locations = gradientLocations; // but at the same time as `NSARRA` the self.layer.startPoint = startpoint; // 0 to 1 from self.layer.endPoint = endPoint; // to 0 to 1
Comments
Post a Comment