using System;
using UIKit;
using System.Drawing;
using CoreAnimation; namespace PMM
{
public class ProgressCircleView : UIView
{
protected CAShapeLayer _progressCircle;
protected CAShapeLayer PageGrayCircle;
public override CoreGraphics.CGRect Bounds {
get
{
return base.Bounds;
}
set {
base.Bounds = value;
GrayCircle ();
}
} public ProgressCircleView ()
{
GrayCircle ();
} /// <summary>
/// Redraws the progress circle. If the circle is already on the screen, it removes that one and creates a new one using the
/// current properties of the view
/// </summary>
void RedrawCircle ()
{ var centerPoint = new PointF ((float)this.Bounds.Width , (float)this.Bounds.Height );
UIBezierPath circlePath = UIBezierPath.FromArc (centerPoint, this.Bounds.Width * .5f, (float)(-. * Math.PI), (float)(1.5 * Math.PI), true); _progressCircle = new CAShapeLayer (); _progressCircle.Path = circlePath.CGPath;
_progressCircle.StrokeColor = UIColor.Red.CGColor;
_progressCircle.FillColor = UIColor.Clear.CGColor;
_progressCircle.LineWidth = 5f;
_progressCircle.LineCap = CAShapeLayer.CapRound;
_progressCircle.StrokeStart = 0f;
_progressCircle.StrokeEnd = 0f;
this.Layer.AddSublayer (_progressCircle); }
void GrayCircle()
{
if (_progressCircle != null && _progressCircle.SuperLayer != null) {
_progressCircle.RemoveFromSuperLayer ();
}
var centerPoint = new PointF ((float)this.Bounds.Width , (float)this.Bounds.Height );
UIBezierPath circlePath = UIBezierPath.FromArc (centerPoint, this.Bounds.Width * .5f, (float)(1.5 * Math.PI), (float)(-. * Math.PI), false); PageGrayCircle = new CAShapeLayer (); PageGrayCircle.Path = circlePath.CGPath;
PageGrayCircle.StrokeColor = UIColor.Gray.CGColor;
PageGrayCircle.FillColor = UIColor.Clear.CGColor;
PageGrayCircle.LineWidth = 4f;
PageGrayCircle.LineCap = CAShapeLayer.CapRound;
PageGrayCircle.StrokeStart = 0f;
PageGrayCircle.StrokeEnd = 0f;
this.Layer.AddSublayer (PageGrayCircle);
RedrawCircle ();
} /// <summary>
/// Updates the progress circle.
/// </summary>
/// <param name="progressPercent">The percentage of the progress. Should be a value between 0.0 and 1.0</param>
public void UpdateProgress(float progressPercent) {
_progressCircle.StrokeEnd = progressPercent;
PageGrayCircle.StrokeEnd = - progressPercent;
}
}
}

xamarin.ios 实现圆形进度条的更多相关文章

  1. Xamarin iOS教程之进度条和滚动视图

    Xamarin iOS教程之进度条和滚动视图 Xamarin iOS 进度条 进度条可以看到每一项任务现在的状态.例如在下载的应用程序中有进度条,用户可以很方便的看到当前程序下载了多少,还剩下多少.Q ...

  2. iOS学习-圆形进度条

    效果: #import <UIKit/UIKit.h> @interface HsProfitRatePieWidgets : UIView { UILabel *_textLabel; ...

  3. iOS之UI--Quartz2D的入门应用--重绘下载圆形进度条

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  4. [iOS]圆形进度条及计时功能

    平时用战网安全令的时候很喜欢圆形倒计时的效果,然后简单看了一下Android的圆形进度条,后来又写了一个IOS的.整体界面参照IOS系统的倒计时功能,顺便熟悉了UIPickerView的一些特性的实现 ...

  5. IOS 圆形进度条

    // // CCProgressView.h // Demo // // Created by leao on 2017/8/7. // Copyright © 2017年 zaodao. All r ...

  6. iOS开发笔记-根据frame大小动态调整fontSize的自适应文本及圆形进度条控件的实现

    最近同样是新App,设计稿里出现一种圆形进度条的设计,如下: 想了想,圆形进度条实现起来不难,但是其中显示百分比的文本确需要自适应,虽然可以使用时自己设定文本字体的大小,但是这样显得很麻烦,也很low ...

  7. 移动端纯CSS3制作圆形进度条所遇到的问题

    近日在开发的页面中,需要制作一个动态的圆形进度条,首先想到的是利用两个矩形,宽等于直径的一半,高等于直径,两个矩形利用浮动贴在一起,设置overflow:hidden属性,作为盒子,内部有一个与其宽高 ...

  8. Xamarin XAML语言教程Xamarin.Forms中构建进度条

    Xamarin XAML语言教程Xamarin.Forms中构建进度条 ProgressBar被称为进度条,它类似于没有滑块的滑块控件.进度条总是水平放置的.本节将讲解如何使用进度条. 注意:进度条在 ...

  9. android 自定义控件——(四)圆形进度条

    ----------------------------------↓↓圆形进度条(源代码下有属性解释)↓↓---------------------------------------------- ...

随机推荐

  1. 制作Html标签以及表单、表格内容

    制作Html一般用DW(......),Html全称为(Hyper Text Markup Language   超文本标记语言) 文本就是平常电脑上的文本文档,只能存储文字,而超文本文档可以存储音乐 ...

  2. Atitit html5 Canvas 如何自适应屏幕大小

    Atitit  html5 Canvas 如何自适应屏幕大小     可以用JS监控屏幕大小,然后调整Canvas的大小.在代码中加入JS 1 2 3 4 5 6 7 $(window).resize ...

  3. asp.net 站点重启

    有时一些特殊情况需要重启站点,在System.Web.dll程序集下HttpRuntime类下有一个静态方法UnloadAppDomain,使用这个方法可以重启站点: protected void b ...

  4. VS报错:The build tools for v140 (Platform Toolset = 'v140') cannot be found

    VS低版本打开高版本常会出现的错: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build usi ...

  5. 工作单元模式(UnitOfWork)学习总结

    工作单元的目标是维护变化的对象列表.使用IUnitOfWorkRepository负责对象的持久化,使用IUnitOfWork收集变化的对象,并将变化的对象放到各自的增删改列表中, 最后Commit, ...

  6. Kruskal算法(二)之 C++详解

    本章是克鲁斯卡尔算法的C++实现. 目录 1. 最小生成树 2. 克鲁斯卡尔算法介绍 3. 克鲁斯卡尔算法图解 4. 克鲁斯卡尔算法分析 5. 克鲁斯卡尔算法的代码说明 6. 克鲁斯卡尔算法的源码 转 ...

  7. NSIS使用教程(安装包制作安装文件教程,如何封装打包文件) 中文版

    nsis中文版(Nullsoft Scriptable Install System)是一个专业的开源的可以用来封闭Windows程序的实用工具,是一个开源的 Windows 系统下安装程序制作程序. ...

  8. U3D中的 Coroutine程序 解析

    今天咱就说说协同程序coroutine. 什么是协同程序 先说说啥是协程:它的表现形式非常像线程,对线程有过接触的朋友可能更理解我这句话的意思,你没接触过线程,那么理解它会有一些难度.但是它不存在线程 ...

  9. Hadoop阅读笔记(四)——一幅图看透MapReduce机制

    时至今日,已然看到第十章,似乎越是焦躁什么时候能翻完这本圣经的时候也让自己变得更加浮躁,想想后面还有一半的行程没走,我觉得这样“有口无心”的学习方式是不奏效的,或者是收效甚微的.如果有幸能有大牛路过, ...

  10. 15款免费的 HTML5/CSS3 响应式网页模板

    如果你想快速制作出一个优秀的网站,网站模板一定是必不可少的.网页设计师和开发人员也可以从网站模板入手,学习先进的布局方式和编码风格.下面这个列表为大家挑选了15款免费的 HTML5/CSS3 响应式网 ...