How to make a gradient TopLeft-BottomRight?
Erel's code draws Top-Bottom.
Erel's code draws Top-Bottom.
B4X:
Sub SetGradient(v As View, color1 As Int, color2 As Int, Replace As Boolean)
Dim NaObj As NativeObject = Me
NaObj.RunMethod("SetGradient::::",Array(v,NaObj.ColorToUIColor(color1),NaObj.ColorToUIColor(color2), Replace))
End Sub
#If OBJC
- (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2 :(BOOL)replace{
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil];
gradient.frame = View.bounds;
if (replace)
[View.layer replaceSublayer:View.layer.sublayers[0] with:gradient];
else
[View.layer insertSublayer:gradient atIndex:0];
}
#end if