protected override void OnElementChanged(ElementChangedEventArgs <FAB.Forms.FloatingActionButton> e) { base.OnElementChanged(e); if (e.NewElement != null) { var fab = new MNFloatingActionButton(); fab.Frame = new CoreGraphics.CGRect(0, 0, 24, 24); this.SetNativeControl(fab); this.UpdateStyle(); this.Control.TouchCancel += this.Fab_TouchUpInside; } }
private async static Task SetImageAsync(ImageSource source, nfloat widthRequest, nfloat heightRequest, MNFloatingActionButton targetButton) { var handler = GetHandler(source); using (UIImage image = await handler.LoadImageAsync(source)) { UIGraphics.BeginImageContext(new CoreGraphics.CGSize(widthRequest, heightRequest)); image.Draw(new CoreGraphics.CGRect(0, 0, widthRequest, heightRequest)); using (var resultImage = UIGraphics.GetImageFromCurrentImageContext()) { UIGraphics.EndImageContext(); using (var resizableImage = resultImage.CreateResizableImage(new UIEdgeInsets(0f, 0f, widthRequest, heightRequest))) { targetButton.CenterImageView.Image = resizableImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); } } } }