Graphics and Animation in iOS
using UIKit;
using CoreGraphics;
using Foundation;
namespace GraphicsAnimation
{
	public class TriangleView : UIView
	{
		CGPath path;
		public TriangleView ()
		{
			BackgroundColor = UIColor.White;
		}
		public override void Draw(CGRect rect)
		{
			base.Draw (rect);
			using(var g=UIGraphics.GetCurrentContext()){
				//set up drawing attributes
				g.SetLineWidth(10);
				UIColor.Blue.SetFill ();
				//UIColor.Purple.SetFill ();
				//UIColor.Black.SetStroke ();
				UIColor.Red.SetStroke();
				//create geometry
				path = new CGPath ();
				path.AddLines (new CGPoint[]{new CGPoint(100,200),new CGPoint(160,100),new CGPoint(220,200)});
				path.CloseSubpath();
//use a dashed line
				g.SetLineDash(0, new nfloat[]{10,4});
				//add geometry to graphics context and draw it
				g.AddPath(path);
g.DrawPath(CGPathDrawingMode.FillStroke);
				// add the path back to the graphics context so that it is the current path
				g.AddPath (path);
				// set the current path to be the clipping path
				g.Clip ();
				using (CGColorSpace rgb = CGColorSpace.CreateDeviceRGB()) {
					CGGradient gradient = new CGGradient (rgb, new CGColor[] {
						UIColor.Blue.CGColor,
						UIColor.Yellow.CGColor
					});
// draw a linear gradient
					g.DrawLinearGradient (
						gradient, 
						new CGPoint (path.BoundingBox.Left, path.BoundingBox.Top), 
						new CGPoint (path.BoundingBox.Right, path.BoundingBox.Bottom), 
						CGGradientDrawingOptions.DrawsBeforeStartLocation);
				}
}
		}
	}
}
public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
			TriangleView   triangleView=new TriangleView{Frame=UIScreen.MainScreen.Bounds};
			View.AddSubview (triangleView);
		}
_}([$SW[`1OI}5S.jpg)
Graphics and Animation in iOS的更多相关文章
- UIKit,Core Data , Core Graphics, Core Animation,和OpenGLES框架
		
iOS的主要框架介绍 框架是一个目录,这个目录包含了共享库,访问共享库里代码的头文件,和其它的图片和声音的资源文件.一个共享库定义的方法或函数可以被应用程序调用. IOS提供了很多你可以在应用程序 ...
 - (转) [it-ebooks]电子书列表
		
[it-ebooks]电子书列表 [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...
 - Designing for iOS: Graphics & Performance
		
http://robots.thoughtbot.com/designing-for-ios-graphics-performance [原文] In the previous article, w ...
 - iOS——Core Animation 知识摘抄(四)
		
原文地址http://www.cocoachina.com/ios/20150106/10840.html 延迟解压 一旦图片文件被加载就必须要进行解码,解码过程是一个相当复杂的任务,需要消耗非常长的 ...
 - iOS——Core Animation 知识摘抄(一)
		
本文是对http://www.cocoachina.com/ios/20150104/10814.html文章的关键段落的摘抄,有需要的看原文 CALayer和UIView的关系: CALayer类在 ...
 - [iOS Animation]-CALayer 性能优化
		
性能优化 代码应该运行的尽量快,而不是更快 - 理查德 在第一和第二部分,我们了解了Core Animation提供的关于绘制和动画的一些特性.Core Animation功能和性能都非常强大,但如果 ...
 - [iOS Animation]-CALayer 显示方式
		
寄宿图 图片胜过千言万语,界面抵得上千图片 ——Ben Shneiderman 我们在第一章『图层树』中介绍了CALayer类并创建了一个简单的有蓝色背景的图层.背景颜色还好啦,但是如果它仅仅是展现了 ...
 - IOS动画(Core Animation)总结 (参考多方文章)
		
一.简介 iOS 动画主要是指Core Animation框架.官方使用文档地址为:Core Animation Guide. Core Animation是IOS和OS X平台上负责图形渲染与动画的 ...
 - iOS 底层框架的浅析
		
1.简介 IOS是由苹果公司为iPhone.iPod touch和iPad等设备开发的操作系统. 2.知识点 iPhone OS(现在叫iOS)是iPhone, iPod touch 和 iPad 设 ...
 
随机推荐
- Spring配置SessionFactory
			
1.不用dataSource引入hibernate.cfg.xml <bean id="sessionFactory" class="org.springframe ...
 - UVa11762 Race to 1
			
期望DP 一个数只能分解成不大于它的数,那么转移构成拓扑关系. 试了一下预处理出不大于x的质数个数,然而程序并没有变快 /*by SilverN*/ #include<algorithm> ...
 - 高阶函数之函数柯里化function currying
			
var cost = (function(){ var args = []; return function(){ if(arguments.length === 0){ ...
 - 移动端H5多平台分享实践--摘抄
			
作者:大漠 日期:2018-01-20 点击:628 mobile 编辑推荐: 掘金是一个高质量的技术社区,从 CSS 到 Vue.js,性能优化到开源类库,让你不错过前端开发的每一个技术干货. 点击 ...
 - JVM指令助记符
			
以下只是JVM指令助记符,关于JVM指令的详细内容请阅读<JVM指令详解> 变量到操作数栈:iload,iload_,lload,lload_,fload,fload_,dload,dlo ...
 - 标准C程序设计七---33
			
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
 - java string中indexOf()常用用法
			
Java中字符串中子串的查找共有四种方法,如下: 1.int indexOf(String str) :返回第一次出现的指定子字符串在此字符串中的索引. 2.int indexOf(String st ...
 - .NET中JSON的序列化和反序列化的几种方式
			
一.什么是JSON JSON(JavaScript Object Notation, JS 对象简谱) 是一种轻量级的数据交换格式.它基于ECMAScript(欧洲计算机协会制定的js规范)的一个子集 ...
 - Classical method of machine learning
			
PCA principal components analysis kmeans bayes spectral clustering svm EM hidden Markov models deep ...
 - CodeForces - 11D A Simple Task
			
Discription Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycl ...