首页 > Windows开发 > 详细

Drawing Images and Text

时间:2015-05-06 22:32:23      阅读:203      评论:0      收藏:0      [点我收藏+]

using System;
using UIKit;
using Foundation;
using CoreGraphics;
namespace GraphicsAnimation
{
public class DrawnImageView : UIView
{
public DrawnImageView ()
{
BackgroundColor = UIColor.White;
}
public override void Draw(CGRect rect)
{
base.Draw (rect);
using(var g=UIGraphics.GetCurrentContext())
{
g.ScaleCTM (1,-1);//画出来的图像默认是倒立的
g.TranslateCTM (0,-Bounds.Height);
g.DrawImage (rect,UIImage.FromFile("MyImage.png").CGImage);
float fontSize = 35f;
g.TranslateCTM (0,fontSize);
g.SetLineWidth (1.0f);
g.SetStrokeColor (UIColor.Yellow.CGColor);
g.SetFillColor (UIColor.Red.CGColor);
//g.SetShadow (new SizeF (5, 5), 0, UIColor.Blue.CGColor);
g.SetShadow(new CGSize(5,5),0,UIColor.Blue.CGColor);
g.SetTextDrawingMode (CGTextDrawingMode.FillStroke);
g.SelectFont ("Helvetica", fontSize, CGTextEncoding.MacRoman);

// show the text
g.ShowText ("Hello Core Graphics");

}
}
}
}

————————————————

 #region View lifecycle

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


DrawnImageView drawnImageView = new DrawnImageView { Frame=UIScreen.MainScreen.Bounds};
View.AddSubview (drawnImageView);
}
运行结果:
技术分享

 

Drawing Images and Text

原文:http://www.cnblogs.com/bubugao/p/4483285.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!