Search code examples
nativeuicolorj2objc

j2objc java extends native uicolor


how can i extends the UIColor in java code example like using native methods.

So j2objc able to compile the java class extends with UIColor.

I'm not sure how to code the extends part.

Please help.


Solution

  • You can't with j2objc, as classes must by compilable by a Java compiler (such as javac), and there's no UIColor Java source or class file. That said, it would be easy to create your own color class that can create a UIColor when asked, something like:

    class MyColor {
      float red, green, blue, alpha;
    ...
      native Object toUIColor() /*-[
        return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
      ]-*/;