Quantcast
Channel: 清风徐来,水波不兴 » CoreGraphics
Browsing all 9 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

CoreGraphics 实用函数

一.绘制单色矩形 1.获取当前的图形上下文。 2.设置绘制填充色。 3.使用填充色填充指定矩形区域。 CGRect rect = CGRectMake(0, 0, 50, 30); CGContextRef context = UIGraphicsGetCurrentContext(); CGColorRef redColor = [UIColor colorWithRed:1.0...

View Article



Image may be NSFW.
Clik here to view.

CoreGraphics之gloss gradients

一 .效果图 gloss gradients效果图,其上所有颜色通过单个背景色参数导出。 二.物理模型 物理光照模型如下,模拟光线照射到半透明玻璃透镜上。 弧B直接反射光源光线,其中从上到下的反射强度不同; 弧C反射的是经过透镜聚焦到C上又散射的光线,其色度和亮度与背景色有变化。 弧A由于透镜的半透明效果而有阴影。 由于透镜表明不是平的,所以不管亮色和暗色部分都不是线性变化的。 三.具体实现...

View Article

iOS截屏代码

在代码中截取当前屏幕,可在当前视图控制器中使用以下代码。 -(UIImage *) toImage{ UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage...

View Article

视图抖动效果

模仿iPhone上长按图标删除程序时的图标抖动效果。 - (void)shakeStatus:(BOOL)enabled { if (enabled) { CGFloat rotation = 0.03; CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"transform"]; shake.duration =...

View Article

UIImage Resize相关

一.对UIImage进行Resize相关问题的总结,提供了对UIImage进行各种操作的源代码。 Resize a UIImage the right way 源代码 UIImage Alpha层相关功能 UIImage+Alpha.h UIImage+Alpha.m 生成圆角图片图片代码 UIImage+RoundedCorner.h UIImage+RoundedCorner.m...

View Article


Image may be NSFW.
Clik here to view.

轮盘拖动旋转效果实现

一.问题 有如图所示轮盘图,需要实现的效果是手指按住轮盘环,顺时针或逆时针拖动,轮盘随着手指旋转,当放开手指时,轮盘会将左侧指针指向的扇区块的中部对准左侧指针。左侧指针指向的扇区块为亮色(alpha=1),其他扇区块为暗色(alpha=0.6)。 二.实现思路...

View Article

Transform – iOS视图几何变换

一.Quartz 2D与CTM 1.Quartz 2D Quartz 2D是二维画图引擎,使用画笔模型( painter’s model ),每次画图操作都是在画布(canvas)上添加一层,称之为页(Page),后面画的页会覆盖前面画的页,所以要控制操作顺序。 Quartz 2D的操作目标是CGContextRef对象,CGContextRef是一种称之为图形上下文(graphics...

View Article

Image may be NSFW.
Clik here to view.

饼状图的绘制

学习开源代码BNPieChart中饼状图的绘制流程,目的是绘制如下图形。 一.获取饼状图大小及各个扇区尺寸 根据给定的Frame计算出饼状图的圆心(centerX,centerY)以及半径(radius),设置需要绘制的扇区数组,此处取7个扇区,其所占比例分别为0.1,0.2,0.1,0.1,0.3,0.1,0.1,总和为1。 二.绘制背景圆形...

View Article


CGRect使用技巧

在iOS开发中经常需要处理点,大小以及矩形,对应的数据结构分别为CGPoint,CGSize,CGRect,这些数据结构都是C结构体,定义分别如下: CGPoint { CGFloat x; CGFloat y; }; CGSize { CGFloat width; CGFloat height; }; struct CGRect { CGPoint origin; CGSize size; };...

View Article

Browsing all 9 articles
Browse latest View live




Latest Images