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. Winform文件下载之WinINet

    在C#中,除了webclient我们还可以使用一组WindowsAPI来完成下载任务.这就是Windows Internet,简称 WinINet.本文通过一个demo来介绍WinINet的基本用法和 ...

  2. Senparc.Weixin.MP SDK 微信公众平台开发教程(十):多客服接口说明

    微信官方的多客服接口原理是通过用户发送的信息,开发者服务器返回一条指定类型的响应信息,使用户的对话状态切换到官方的多客服状态(持续一段时间),这段时间内用户发送的所有信息都不会到达开发者的服务器,而是 ...

  3. ehcache2拾遗之cache持久化

    问题描述 应用在使用过程中会需要重启等,但是如果ehcache随着应用一起重启,那么刚重启的时候就会出现大量的miss,需要一定的访问量来重建缓存,如果缓存能够持久化,重启之后可以复用将会有助于缓解重 ...

  4. 为什么eclipse中启动tomcat后,浏览器中出现404?

    问题描述: tomcat压缩包加压后,启动lib文件夹下面的startup.bat,在浏览器中输入http://localhost:8080/后出现熟悉的界面. 但是在eclipse中,jsp可以正常 ...

  5. Laravel5.0学习--02 实例进阶

    本文以laravel5.0.22为例. 本节以新建一个简单的博客作为实例. 准备工作 数据库配置 .env文件(也可以直接修改config/database.php) DB_HOST=localhos ...

  6. 一条Select语句丛生到死的处理过程

    以一条普通的“select * from table order by …”语句为例.图2-21中显示为该语句在数据库中各个组件之间的处理过程,各个步骤分别代表: (1)select语句通过网络传送给 ...

  7. css_04之显示、定位

    1.显示方式:display:取值:none(隐藏,不占页面空间,脱离文档流)/block(元素变为块级)/inline(元素变为行内)/inline-block(元素变为行内块): 2.显示效果:v ...

  8. SoapUI测试WS接口实战

    引文: 本文讨论以下问题: 视频播放功能如何进行压力测试? 进行webservices接口测试时,用LR和soapui哪个工具更好? 1 测试需求 前几天接到一项压力测试的任务:视频播放功能的并发压力 ...

  9. 锋利的jQuery——19个jQuery 常用片段整理

    /** * Created by yu on 2016/11/20 0020. */// 1.禁用页面右键菜单$(function () { $(document).on('contextmenu', ...

  10. Android属性动画之ObjectAnimator控制

    Android为我们提供了大量的动画效果,如何通过这些动画来达到我们需要的效果呢?今天就为大家总结一下ObjectAnimator动画控制事件. 该项目的的布局文件只有两个控件:ImageView和B ...