sushihangover/SVGKit.Binding

How to use SVGKLayeredImageView?

Opened this issue · 11 comments

Hi!
Thank you for this binding and NuGet package!

I wonder, how do I use SVGKLayeredImageView in this binding?
Seems like initWithImage method is missing in the C# surface.

Please advise.

Seems the sharpie create the correct BaseType reference:

// @interface SVGKLayeredImageView : SVGKImageView
[BaseType (typeof(SVGKImageView))]
interface SVGKLayeredImageView
{
}

But btouch does not generate the initWithSVGKImage: export as with the base class' SVGKImageView (initWithSVGKImage:):

            [Export ("initWithSVGKImage:")]
            [CompilerGenerated]
            public SVGKImageView (SVGKImage im)
                    : base (NSObjectFlag.Empty)
            {
                    if (im == null)
                            throw new ArgumentNullException ("im");
                    IsDirectBinding = GetType ().Assembly == global::ApiDefinitions.Messaging.this_assembly;
                    if (IsDirectBinding) {
                            InitializeHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, Selector.GetHandle ("initWithSVGKImage:"), im.Handle), "initWithSVGKImage:");
                    } else {
                            InitializeHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSendSuper_IntPtr (this.SuperHandle, Selector.GetHandle ("initWithSVGKImage:"), im.Handle), "initWithSVGKImage:");
                    }
            }

I just updated to Xamarin 15.5-beta and changes to BTOUCH bgen is failing to build the project as is, I made some changes to get it to compile, but there are some errors showing up in one of my projects when I use the resulting binding. I have to look into this and try 15.4 stable instead to see what the difference is.

@alexsorokoletov

Till I look at it to see what the issue is, you can use the Image property to assign your SVGKImage:

            var x = new SVGKLayeredImageView
            {
                Image = new SVGKImage("Media/Sushi.svg")
            };

@alexsorokoletov Try nuget version 1.0.4 and let me know.

I wrote a partial SVGKLayeredImageView class to add that .actor. Still confused on why bgen is failing to do it.

I wrote a quick test to invert the layer colors to make sure that the SVG layers are being created, etc..

            void RecurseLayers(CALayer[] layers)
            {
                foreach (var layer in layers)
                {
                    if (layer is CAShapeLayer && (layer as CAShapeLayer).FillColor != null)
                        (layer as CAShapeLayer).FillColor = UIColor.FromCGColor((layer as CAShapeLayer).FillColor).Inverse().CGColor;
                    if (layer.Sublayers != null)
                        RecurseLayers(layer.Sublayers);
                }
            }
            var imageView = new SVGKLayeredImageView(new SVGKImage("Media/Sushi.svg"));
            imageView.Frame = View.Frame;
            View.Add(imageView);
            timer = NSTimer.CreateRepeatingScheduledTimer(2, (_) => InvokeOnMainThread(() => RecurseLayers(imageView.Layer.Sublayers)));

Seems to work fine, but not sure the about how to properly size/scale a SVGKLayeredImageView vs SVGKFastImageView/SVGImageView...

out

@alexsorokoletov Have you been able to try the new version?

No, not yet. I will test it next week and let you know.
Thank you for fixing this so quickly.

@sushihangover new update looks good, but for some reason it broke my build.

 ld: framework not found IOSurface for architecture armv7
clang : error : linker command failed with exit code 1 (use -v to see invocation) 

For now I rolled back to 1.0.3

framework not found IOSurface for architecture armv7

@alexsorokoletov Using Xcode 8?

Hmm, most probably XCode 9. Let me check what is on the CI server

Indeed XCode 8 on the CI @sushihangover

I think we can close that issue. Method is available in C#, when we update CI to XCode 9, I will update the app. Thank you, @sushihangover