Xamarin forms increase ProgressBar height

青春壹個敷衍的年華 提交于 2019-12-07 19:07:41

问题


I have been developing a Xamarin forms application. I want to increase the height of the progress bar control. I used custom renders to change the color of the progress control. But I couldn't find any way to increase the height. Please help me. following is my Custom render class.

public class MyProgressBarRenderer:ProgressBarRenderer
{
    protected override void OnElementChanged (
         ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
    {
        base.OnElementChanged (e);

        Control.ProgressTintColor =  Color.FromHex ("#254f5e").ToUIColor();
    }
}

回答1:


Add this override to MyProgressBarRenderer, and adjust Y as necessary....

using UIKit; 
using CoreGraphics;
......
public override void LayoutSubviews()
{
   base.LayoutSubviews();

   var X = 1.0f;
   var Y = 5.0f;

   CGAffineTransform transform = CGAffineTransform.MakeScale(X,Y);
   this.Transform = transform; 
}




回答2:


There is small issue in the iOS renderer code try using

this.Control.Transform = transform; 

instead of

this.Transform = transform;


来源:https://stackoverflow.com/questions/33673893/xamarin-forms-increase-progressbar-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!