简体   繁体   English

更改自定义进度栏的高度无法正常运行Xamarin.Forms iOS

[英]Changing height of custom progresssbar not working Xamarin.Forms iOS

i tried to change the height of the progressbar in xamarin.forms using PCL. 我试图使用PCL在xamarin.forms中更改进度栏的高度。 the solution seems to be like this: Xamarin forms increase ProgressBar height 解决方案似乎是这样的: Xamarin表单增加了ProgressBar的高度

on android this is working fine, but on iOS its not working. 在android上,这工作正常,但在iOS上,则无法工作。 any advice? 有什么建议吗?

the color and corner radius change is working! 颜色和拐角半径的更改正在起作用!

my code: 我的代码:

using ZFBookingAid.iOS;
using CoreGraphics;
using Foundation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ProgressBar), typeof(CustomProgressBarRenderer))]
namespace ZFBookingAid.iOS
{
    public class CustomProgressBarRenderer : ProgressBarRenderer
    {
        protected override void OnElementChanged(
         ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
        {
            base.OnElementChanged(e);

            Control.ProgressTintColor = Color.FromRgb(213, 176, 118).ToUIColor();// This changes the color of the progress


            Control.TrackTintColor = Color.FromRgb(255, 255, 255).ToUIColor(); //color where is "no progress"

        }



        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            var X = 0.5f;
            var Y = 30.0f;

            CGAffineTransform transform = CGAffineTransform.MakeScale(X, Y);
            Control.Transform = transform;
            this.ClipsToBounds = true;
            this.Layer.MasksToBounds = true;
            this.Layer.CornerRadius = 5; // This is for rounded corners.

        }
    }
}
public async override void LayoutSubviews()
        {
            await Task.Delay(100);
            base.LayoutSubviews();
            CGAffineTransform transform = CGAffineTransform.MakeScale(1.2f, 2.5f);
            transform.TransformSize(this.Frame.Size);
            this.Transform = transform;
            this.ClipsToBounds = true;
            this.Layer.MasksToBounds = true;


        }

this is how i fixed the height of the progress bar issue. 这就是我固定进度条问题的高度的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM