IOS 绘制条纹背景
@interface NJViewController ()
@property (weak, nonatomic) IBOutlet UITextView *contentView;
- (IBAction)preBtnClick:(id)sender;
- (IBAction)nextBtnClick:(id)sender; @property (nonatomic, assign) int index; @end @implementation NJViewController - (void)viewDidLoad
{
[super viewDidLoad]; // // 1.生成一张以后用于平铺的小图片
CGSize size = CGSizeMake(self.view.frame.size.width, );
UIGraphicsBeginImageContextWithOptions(size , NO, ); // 2.画矩形
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGFloat height = ;
CGContextAddRect(ctx, CGRectMake(, , self.view.frame.size.width, height));
[[UIColor redColor] set];
CGContextFillPath(ctx); // 3.画线条 CGFloat lineWidth = ;
CGFloat lineY = height - lineWidth;
CGFloat lineX = ;
CGContextMoveToPoint(ctx, lineX, lineY);
CGContextAddLineToPoint(ctx, , lineY);
[[UIColor blackColor] set];
CGContextStrokePath(ctx); UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIColor *myColor = [UIColor colorWithPatternImage:image];
self.contentView.backgroundColor = myColor; } - (void)test
{
// 1.生成一张以后用于平铺的小图片
CGSize size = CGSizeMake(self.view.frame.size.width, );
UIGraphicsBeginImageContextWithOptions(size , NO, ); // 2.画矩形
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGFloat height = ;
CGContextAddRect(ctx, CGRectMake(, , self.view.frame.size.width, height));
[[UIColor redColor] set];
CGContextFillPath(ctx); // 3.画线条 CGFloat lineWidth = ;
CGFloat lineY = height - lineWidth;
CGFloat lineX = ;
CGContextMoveToPoint(ctx, lineX, lineY);
CGContextAddLineToPoint(ctx, , lineY);
[[UIColor blackColor] set];
CGContextStrokePath(ctx); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); /*
// 2.将图片写到文件中
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"aaa.png"];
NSLog(@"%@", path); NSData *data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
*/ // UIImage *image = [UIImage imageNamed:@"me"];
// UIColor *myColor = [UIColor colorWithPatternImage:image];
// self.view.backgroundColor = myColor;
} // 今天不要求掌握以下内容
- (IBAction)preBtnClick:(id)sender
{
self.index--; self.contentView.text = [NSString stringWithFormat:@"第%d页", self.index]; CATransition *ca = [[CATransition alloc] init];
ca.type = @"pageCurl"; [self.contentView.layer addAnimation:ca forKey:nil];
} - (IBAction)nextBtnClick:(id)sender
{
self.index++; self.contentView.text = [NSString stringWithFormat:@"第%d页", self.index];
}
IOS 绘制条纹背景的更多相关文章
- 用css实现条纹背景
		我先额外的说一下怎么用CSS绘制三角形: 绘制三角形是把边框加粗,将元素的宽高都设为0,让其余的边框颜色透明,下面我们来看实现的代码: 先把边框的颜色设置成不同颜色: #div{ border-col ... 
- css条纹背景样式、及方格斜纹背景的实现
		一.横向条纹如下代码: background: linear-gradient(#fb3 %, #58a %) 上面代码表示整个图片的上部分20%和下部分20%是对应的纯色,只有中间的部分是渐变色.如 ... 
- iOS中点击背景收键盘
		这一次给大家带来的是ios中点击背景如何收键盘(感觉不错给个赞 
- CSS揭秘 技巧(五):条纹背景
		条纹背景 https://github.com/FannieGirl/ifannie/问题:条纹背景 在设觉设计中无处不在,我们真的可以用css 创建图案吗? 这一章相对还是比较复杂的哦!一起get. ... 
- css条纹背景
		一. 水平条纹 1. 两种颜色: html <div class="stripe"></div> css .stripe{ width: 250px; he ... 
- 利用CCS3渐变实现条纹背景
		本文摘自<CSS揭秘>中国工信出版集团 难题: 不论是在网页设计中,还是在其他传统媒介中(比如杂志和墙纸等),各种尺寸.颜色.角度的条纹图案在视觉设计中无处不在.要想在网页中实现条纹图案, ... 
- [css 揭秘] :CSS揭秘 技巧(五):条纹背景
		条纹背景 https://github.com/FannieGirl/ifannie/问题:条纹背景 在设觉设计中无处不在,我们真的可以用css 创建图案吗? 这一章相对还是比较复杂的哦!一起get. ... 
- 使用android.graphics.Path类自绘制PopupWindow背景
		PopupWindow简单介绍 PopupWindow是悬浮在当前activity上的一个容器,用它能够展示随意的内容. PopupWindow跟位置有关的API有以下几个: showAsDropDo ... 
- C#绘制渐变背景
		//绘制渐变色背景 Graphics g = e.Graphics; LinearGradientBrush linearGradientBrush = new LinearGradientBrush ... 
随机推荐
- LOJ6235 区间素数个数(min_25筛)
			题目链接:LOJ 题目大意:看到题目名字应该都知道是啥了吧. $1\le N\le 10^{11}$. 阉割版 min_25 筛.发现答案实际上就是 min_25 筛中 $g(N,pl)$ 的值.(取 ... 
- remap——ROS中修改订阅的节点名称
			跑数据集或者使用不同传感器时,难免会遇到需要修改topic名称的时候,此时可以有两种做法. 一.直接修改源码.如果有launch文件,则修改launch文件对应的topic 二.直接进行remap操作 ... 
- SQL Server2012如何打开2016的profiler文件
			SQL Server 2012如何打开2016的profiler文件 作者:markjiang7m2 原文地址:https://www.cnblogs.com/markjiang7m2/p/10980 ... 
- ios开发 xcode6以上安装Alcatraz管理插件
			在终端上输入如下命令即可完成安装: curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | ... 
- angularJs解决模态框下echarts不显示问题
			例如:摸态框myModal.html,给它命名一个id,id='myModal'; myModal.html页面想画一个echarts图表 这里是angularJs已经封装好的echarts在html ... 
- 调试JMETER脚本的5种方法
			如果你曾经设计过JMeter脚本,我敢打赌你至少有一次弄清楚Json Extractor无法正常工作的原因.你猜怎么着?我去过那儿! 你知道为什么最好的JMeter Performance Engin ... 
- rgb值转换成16进制
			由于jQuery获取css中的background有时候是rgb值,所以往往需要一个转换函数. 以前觉得难,还写个博客记录,现在觉得好容易. let testColor = "rgb(20, ... 
- 埃氏筛法(求n以内有多少个素数)
			题目大意:给定整数n,请问n以内有多少个素数 思路:想必要判断一个数是否是素数,大家都会了,并且可以在O(根号n)的复杂度求出答案,那么求n以内的素数呢,那样求就显得有点复杂了,下面看一下这里介绍的 
- F. Gourmet and Banquet(贪心加二分求值)
			题目链接:http://codeforces.com/problemset/problem/589/F A gourmet came into the banquet hall, where the ... 
- (转)Linux系统stat指令用法
			<Linux系统stat指令用法> 原文:https://www.cnblogs.com/linux-super-meng/p/3812695.html stat指令:文件/文件系统的详 ... 
