Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to reduce top and bottom padding for a custom bordered button?

$
0
0

I've managed to add left and right padding to my custom bordered button. The code is as below:

[assembly: ExportRenderer (typeof (BorderedButton), typeof (BorderedButtonRenderer))]
namespace DutyFreeCollection.iOS
{
    public class BorderedButtonRenderer : ButtonRenderer
    {
        UIButton btn;

        public BorderedButtonRenderer () {}

        protected override void OnElementChanged (ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged (e);

            if(e.OldElement == null)
            {
                btn = (UIButton) Control;   
                btn.ContentEdgeInsets = new UIEdgeInsets (-20, 20, -20, 20); // Set -20 for top and bot padding, why is the top/bot padding not            
                                                                  //reduced?
            }
        }
    }
}

-20 does not reduce the top and bottom padding. Anyone knows how to reduce top and bottom padding for a custom bordered Button?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>