Hi
Can I set a gradient color on a button ?
thank you
Can I set a gradient color on a button ?
thank you
Last edited:
SetButtonGradient(Button1,Colors.Black,Colors.White)
Sub SetButtonGradient(aButton As Button, Color1 As Int, Color2 As Int)
Dim NaObj As NativeObject = Me
NaObj.RunMethod("SetGradient:::",Array(aButton,NaObj.ColorToUIColor(Color1),NaObj.ColorToUIColor(Color2)))
End Sub
#If OBJC
- (void)SetGradient: (UIButton*) Button :(UIColor*) Color1 :(UIColor*) Color2{
CAGradientLayer *Gradient = [CAGradientLayer layer];
Gradient.colors = [NSArray arrayWithObjects: (id)Color1.CGColor, (id)Color2.CGColor, nil];
Gradient.frame = Button.bounds;
[Button.layer insertSublayer:Gradient atIndex:0];
}
#End If
SetButtonGradient(BTN_0,Colors.ARGB(0xFF,0x5B,0x8F,0xEA),Colors.ARGB(0xFF,0x19,0x47,0xEF))
RemoveSubLayers(BTN_0)
Sub SetButtonGradient(aButton As Button, Color1 As Int, Color2 As Int)
Dim NaObj As NativeObject = Me
NaObj.RunMethod("SetGradient:::",Array(aButton,NaObj.ColorToUIColor(Color1),NaObj.ColorToUIColor(Color2)))
End Sub
#If OBJC
- (void)SetGradient: (UIButton*) Button :(UIColor*) Color1 :(UIColor*) Color2{
CAGradientLayer *Gradient = [CAGradientLayer layer];
Gradient.colors = [NSArray arrayWithObjects: (id)Color1.CGColor, (id)Color2.CGColor, nil];
Gradient.frame = Button.bounds;
[Button.layer insertSublayer:Gradient atIndex:0];
}
#End If
Sub RemoveSubLayers(aButton As Button)
Dim NaObj As NativeObject = aButton
NaObj.GetField("layer").SetField("sublayers",Null)
End Sub