Chris Guanzon Active Member Licensed User Longtime User Apr 8, 2021 #1 Hello, can it create a gradient color with direction like in b4a? In b4a, I used this code: B4X: Dim gradient As GradientDrawable Dim clrs(2) As Int clrs(0) = btnGradientColor1 clrs(1) = btnGradientColor2 gradient.Initialize("TR_BL", clrs) Is there a "TR_BL" gradient for b4i? https://www.b4x.com/android/forum/threads/set-gradient-color-to-a-view.65242/
Hello, can it create a gradient color with direction like in b4a? In b4a, I used this code: B4X: Dim gradient As GradientDrawable Dim clrs(2) As Int clrs(0) = btnGradientColor1 clrs(1) = btnGradientColor2 gradient.Initialize("TR_BL", clrs) Is there a "TR_BL" gradient for b4i? https://www.b4x.com/android/forum/threads/set-gradient-color-to-a-view.65242/
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2021 #2 You can use BitmapCreator to create any gradient you like and then put it in an ImageView behind the actual view. Upvote 0
You can use BitmapCreator to create any gradient you like and then put it in an ImageView behind the actual view.
Chris Guanzon Active Member Licensed User Longtime User Apr 8, 2021 #3 Erel said: You can use BitmapCreator to create any gradient you like and then put it in an ImageView behind the actual view. Click to expand... Can I use this to button and panel? Upvote 0
Erel said: You can use BitmapCreator to create any gradient you like and then put it in an ImageView behind the actual view. Click to expand... Can I use this to button and panel?
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2021 #4 Put an ImageView inside a panel or put an ImageView behind the button. If you want to use the inline code to make the gradient then add these two lines: B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); Upvote 0
Put an ImageView inside a panel or put an ImageView behind the button. If you want to use the inline code to make the gradient then add these two lines: B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 );
Chris Guanzon Active Member Licensed User Longtime User Apr 8, 2021 #5 Erel said: Put an ImageView inside a panel or put an ImageView behind the button. If you want to use the inline code to make the gradient then add these two lines: B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); Click to expand... I added these two lines B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); B4X: #If OBJC - (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2{ CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil]; gradient.frame = View.bounds; [View.layer insertSublayer:gradient atIndex:0]; } #end if but got an error while compiling. Error: B4X: Error: ** BUILD FAILED ** The following build commands failed: CompileC /Users/arthurgalenzoga/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o /Users/arthurgalenzoga/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure) Upvote 0
Erel said: Put an ImageView inside a panel or put an ImageView behind the button. If you want to use the inline code to make the gradient then add these two lines: B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); Click to expand... I added these two lines B4X: gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); B4X: #If OBJC - (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2{ CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.startPoint = CGPoint(x: 0, y: 0); gradient.endPoint = CGPoint(x: 1, y: 1 ); gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil]; gradient.frame = View.bounds; [View.layer insertSublayer:gradient atIndex:0]; } #end if but got an error while compiling. Error: B4X: Error: ** BUILD FAILED ** The following build commands failed: CompileC /Users/arthurgalenzoga/Downloads/B4iBuildServer/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o /Users/arthurgalenzoga/Downloads/B4iBuildServer/UploadedProjects/<user id>/B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure)
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2021 #6 Correct code: B4X: gradient.startPoint = CGPointMake(0, 0); gradient.endPoint = CGPointMake(1, 1); Upvote 0
Chris Guanzon Active Member Licensed User Longtime User Apr 8, 2021 #7 Erel said: Correct code: B4X: gradient.startPoint = CGPointMake(0, 0); gradient.endPoint = CGPointMake(1, 1); Click to expand... thanks sir @Erel , here's the code I used: B4X: - (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2{ CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = View.bounds; gradient.startPoint = CGPointZero; gradient.endPoint = CGPointMake(1, 1); gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil]; [View.layer insertSublayer:gradient atIndex:0]; } Upvote 0
Erel said: Correct code: B4X: gradient.startPoint = CGPointMake(0, 0); gradient.endPoint = CGPointMake(1, 1); Click to expand... thanks sir @Erel , here's the code I used: B4X: - (void)SetGradient: (UIView*) View :(UIColor*) Color1 :(UIColor*) Color2{ CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = View.bounds; gradient.startPoint = CGPointZero; gradient.endPoint = CGPointMake(1, 1); gradient.colors = [NSArray arrayWithObjects:(id)Color1.CGColor, (id)Color2.CGColor, nil]; [View.layer insertSublayer:gradient atIndex:0]; }