iOS Question Native Object

stevel05

Expert
Licensed User
Longtime User
I'm trying to set a background image to a label using Native object as in the attached project, but get a -[NSMethodSignature getArgumentTypeAtIndex:]: index (2) out of bounds [0, 1] error.

According to code I've found it should work simply as:

B4X:
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
label.backgroundColor = color;

UIColor is created as a <B4INativeObject: kCGColorSpaceModelPattern 1 > object, but it won't assign using the "backgroundColor" property.

Am I using the Native Object correctly?

B4X:
    Dim img As Bitmap
    img.Initialize(File.DirAssets,"IconBackground (10).png")

    Dim NObj,UIColor As NativeObject

    UIColor.Initialize("UIColor")
    UIColor = UIColor.RunMethod("colorWithPatternImage:",Array(img))
    Log(UIColor)

    NObj = Label1
    NObj.RunMethod("backgroundColor",Array(UIColor))
 

Attachments

  • CT.zip
    17.3 KB · Views: 321

stevel05

Expert
Licensed User
Longtime User
Great thanks.

B4i is working really well so far, just got to get over the learning curve for ios.
 
Upvote 0

DoctorDebug

Member
Licensed User
Longtime User
B4I is genius. I do have a question about the gradients... how would one put a gradient on a button (used GradientDrawable in B4A). Thanks.
 
Upvote 0
Top