예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Set these properties to AutoLayout can be overrided.
            View1.TranslatesAutoresizingMaskIntoConstraints = true;
            View2.TranslatesAutoresizingMaskIntoConstraints = true;
            View3.TranslatesAutoresizingMaskIntoConstraints = true;
            View4.TranslatesAutoresizingMaskIntoConstraints = true;

            //Arrange views so they are of equal heights and fill screen.
            View1.Frame = new RectangleF(0, 0, (float)View.Frame.Width, (float)View.Frame.Height / 4);
            View2.Frame = new RectangleF(0, (float)View1.Frame.Height, (float)View1.Frame.Width, (float)View1.Frame.Height);
            View3.Frame = new RectangleF(0, (float)(View1.Frame.Height * 2), (float)View1.Frame.Width, (float)View1.Frame.Height);
            View4.Frame = new RectangleF(0, (float)(View1.Frame.Height * 3), (float)View1.Frame.Width, (float)View1.Frame.Height);

            //Set colours of controls.
            View1.BackgroundColor = UIColour.Green;
            View2.BackgroundColor = UIColour.LightBlue;
            View3.BackgroundColor = UIColour.DarkBlue;
            View4.BackgroundColor = UIColour.Cream;

            var image     = new SVGKImage(NSBundle.MainBundle.BundlePath + "/Tester.svg");
            var imageView = new SVGKFastImageView(image);

            View.Add(imageView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var image     = new SVGKImage(Path.Combine(NSBundle.MainBundle.BundlePath, "Media/Joker.svg"));
            var imageView = new SVGKFastImageView(image);

            imageView.Frame = View.Frame;
            View.Add(imageView);

            var uriString = "https://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg";
            var button    = new UIButton(UIButtonType.InfoDark);

            button.Frame = new CoreGraphics.CGRect(100, 40, 100, 40);
            button.SetTitle(uriString, UIControlState.Normal);
            button.TouchUpInside += async(sender, e) =>
            {
                using (HttpClient client = new HttpClient())
                    using (HttpResponseMessage response = await client.GetAsync(uriString))
                        using (HttpContent content = response.Content)
                        {
                            string result = await content.ReadAsStringAsync();

                            if (result != null)
                            {
                                var svgSource = SVGKSourceString.SourceFromContentsOfString(result);
                                var svgImage  = SVGKImage.ImageWithSource(svgSource);
                                imageView.Image       = svgImage;
                                imageView.Frame       = View.Frame;
                                imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                            }
                        }
            };
            View.Add(button);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var image     = new SVGKImage("Media/Sushi.svg");
            var imageView = new SVGKFastImageView(image);

            imageView.Frame = View.Frame;
            View.Add(imageView);
        }