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 ...
随机推荐
- How to generate rtabmap with a Realsense D435 or Xtion Pro Live?(如何使用Realsense D435或者Xtion Pro Live生成rtabmap?)
Ubuntu16.04,ROS kinetic 1.在ROS中安装rtabmap_ros包 sudo apt-get install ros-kinetic-rtabmap-ros 2. RGB-D相 ...
- Oracle 12c登陆sys用户的方法
本机安装过oracle 12c之后,发现用sql plus执行命令conn sys/change_on_install as sysdba; 提示如下图: 后在网上搜索此问题,需要先登陆system账 ...
- ios一个自定义的下拉多选菜单
前段时间项目刚好要做到条件筛选菜单,正好找到一些别人写的,结合自己实际需求进行优化修改,一个实用的多条件筛选菜单,根据其他的下拉进行一些改进. 点击后返回点击文字显示 github地址:https:/ ...
- Bitbucekt Reference
Bitbucket Server installation guide https://confluence.atlassian.com/bitbucketserver/bitbucket-serve ...
- PHPExcel探索之旅---阶段三 绘制图表
利用PHPExcel插件进行绘制图表 <?php /** * 使用PHPExcel插件在excel文件中利用其中的数据建立折线图 * */ $dir = dirname(__FILE__); r ...
- 3Ds Max FTL:Virtual device creation failed.
1.在安装完成并激活3DsMax2017中文版后,启动提示:渲染错误消息:FTL: Virtual device creation failed.(中文译:虚拟设备的创建失败). 2.关闭渲染错误消息 ...
- P2375 [NOI2014]动物园 KMP
好,暴力能拿$50pts\space qwq$ 暴力的思路就是一直跳$nxt[j]$,直到它的长度小于串的一半,然后开始计数,当然要接着跳$nxt[j]$ 正解:考虑没有长度要求的(不要求不重合)公共 ...
- postgresql备份数据库
备份数据库:pg_dump -U username -h localhost -f /me.sql 数据库名; 恢复数据库:psql -U username -h localhost -f /me.s ...
- C. Jury Marks 思维题
http://codeforces.com/contest/831/problem/C 做的时候想不到,来了个暴力. 对于每个b[i],枚举每一个a[i],就有1个可能的情况. 然后用vector存起 ...
- (转)Web服务器磁盘满故障深入解析
Web服务器磁盘满故障深入解析 原文:http://blog.51cto.com/oldboy/612351 ############################################# ...