Set gradient color to a view like panel, label, imageview, button,...
Source: http://stackoverflow.com/questions/23074539/programmatically-create-a-uiview-with-color-gradient
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			Source: http://stackoverflow.com/questions/23074539/programmatically-create-a-uiview-with-color-gradient
			
				B4X:
			
		
		
		Sub SetGradient(v As View, color1 As Int, color2 As Int)
    Dim NaObj As NativeObject = Me
    NaObj.RunMethod("SetGradient:::",Array(v,NaObj.ColorToUIColor(color1),NaObj.ColorToUIColor(color2)))
End Sub
#If OBJC
- (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2{
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil];
    gradient.frame = View.bounds;
    [View.layer insertSublayer:gradient atIndex:0];
}
#end if
	Attachments
			
				Last edited: