Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use SVGKLayeredImageView? #5

Open
alexsorokoletov opened this issue Oct 12, 2017 · 11 comments
Open

How to use SVGKLayeredImageView? #5

alexsorokoletov opened this issue Oct 12, 2017 · 11 comments
Assignees
Labels

Comments

@alexsorokoletov
Copy link

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.

@sushihangover
Copy link
Owner

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.

@sushihangover
Copy link
Owner

@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
Copy link
Author

alexsorokoletov commented Oct 13, 2017 via email

@sushihangover
Copy link
Owner

sushihangover commented Oct 13, 2017

@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

@sushihangover
Copy link
Owner

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

@alexsorokoletov
Copy link
Author

alexsorokoletov commented Oct 21, 2017

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

@alexsorokoletov
Copy link
Author

@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

@sushihangover
Copy link
Owner

framework not found IOSurface for architecture armv7

@alexsorokoletov Using Xcode 8?

@alexsorokoletov
Copy link
Author

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

@alexsorokoletov
Copy link
Author

Indeed XCode 8 on the CI @sushihangover

@alexsorokoletov
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants