Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Page1.RootPanel.LoadLayout("1")
'Set gradiant color to views
For Each v As View In Page1.RootPanel.GetAllViewsRecursive
SetGradient(v,Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255)),Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255)), False)
Next
End Sub
Sub Page1_Click
SetGradient(Button1,Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255)),Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255)), True)
End Sub
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