代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
ObjC
】
仿照IOS7键盘解锁
作者:
宝清
/ 发布于
2014/11/17
/
500
#import "A.h" @implementation A - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code UITapGestureRecognizer *touchClearKB=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clearKB:)]; [self addGestureRecognizer:touchClearKB]; } return self; } -(void)clearKB:(UITapGestureRecognizer *)uITapGestureRecognizer { CGPoint point= [uITapGestureRecognizer locationInView:self]; float x=30; float y=30; float w=40; float h=40; float p=5; aa=@[@"ABC",@"DEF",@"GHI",@"JKL",@"MNO",@"PQR",@"STU",@"VWX",@"YZ"]; for (int i=0; i<9; i++) { if (i!=0&&i%3==0) { x=130; y+=h+8; }else { if (i==0) { x=130; }else { x+=w+p; } } CGRect frame=CGRectMake(x, y, w, h); BOOL b= CGPathContainsPoint(CGPathCreateWithRect(frame,nil), nil, point, NO); if (b) { NSLog(@"-->%@",aa[i]); [UIView beginAnimations:@"animation" context:nil]; [UIView setAnimationDuration:1.0f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES]; [UIView commitAnimations]; break; } } } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation.*/ - (void)drawRect:(CGRect)rect { // Drawing code CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [[UIColor grayColor] CGColor]); CGContextFillRect(context, self.frame); // CGContextSetStrokeColorWithColor(context, [[UIColor blueColor] CGColor]) ; // [bp moveToPoint:CGPointMake(30, 90)]; // [bp addLineToPoint:CGPointMake(30, 120)]; // [bp addLineToPoint:CGPointMake(90, 120)]; // [bp addLineToPoint:CGPointMake(90, 90)]; float x=30; float y=30; float w=40; float h=40; float p=5; aa=@[@"ABC",@"DEF",@"GHI",@"JKL",@"MNO",@"PQR",@"STU",@"VWX",@"YZ"]; for (int i=0; i<9; i++) { if (i!=0&&i%3==0) { x=130; y+=h+8; }else { if (i==0) { x=130; }else { x+=w+p; } } [self draw:x withY:y w:w h:h withTxt:[NSString stringWithFormat:@"%d",i] withTxt2:[aa objectAtIndex:i]]; } } -(void)draw:(float)x withY:(float)y w:(float)w h:(float)h withTxt:(NSString *)txt1 withTxt2:(NSString *)txt2 { CGContextRef context=UIGraphicsGetCurrentContext(); //定义填充的颜色,这里我用红色 UIColor* fillColor = [UIColor greenColor]; //定义一个渐变颜色,实现上面那个填充色的渐变 CGColorSpaceRef colorSpace =CGColorSpaceCreateDeviceRGB(); NSArray* innerColorColors = [NSArray arrayWithObjects: (id)[UIColor whiteColor].CGColor, (id)fillColor.CGColor, (id)[UIColor blueColor].CGColor,nil]; CGFloat innerColorLocations[] = {0,0.3,1}; CGGradientRef innerColor =CGGradientCreateWithColors(colorSpace, (CFArrayRef)innerColorColors, innerColorLocations); CGRect frame=CGRectMake(x, y, w, h); UIBezierPath *bp=[UIBezierPath bezierPathWithRoundedRect:frame cornerRadius:40];; [bp closePath]; CGContextSaveGState(context);//先保存当前绘制 [bp addClip];//把此路径裁剪出来,否则渐变的绘制区域是整个当前的图形上下文 float minx=CGRectGetMinX(frame); float miny=CGRectGetMinY(frame); float maxy=CGRectGetMaxY(frame); // CGContextDrawLinearGradient(context, innerColor, CGPointMake(minx, miny), CGPointMake(CGRectGetMaxX(frame), maxy), 0);//绘制渐变 CGContextRestoreGState(context);//恢复绘制的内容到之前的的屏幕上 bp.lineWidth = 0; [bp stroke];//路径绘制 //清理释放内存 CGGradientRelease(innerColor); CGColorSpaceRelease(colorSpace); NSString *num=txt1; NSArray *attribute_v=@[[UIColor whiteColor],[UIFont systemFontOfSize:18]]; NSArray *attribute=@[UITextAttributeTextColor,UITextAttributeFont]; UIFont *font_num = [UIFont systemFontOfSize:18]; CGSize size_num = [num sizeWithFont:font_num constrainedToSize:CGSizeMake(150.0f, 1000.0f) lineBreakMode:UILineBreakModeCharacterWrap]; // [t drawInRect:CGRectMake(minx, miny+8, w, 8) withFont:[UIFont boldSystemFontOfSize:18] lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter]; [num drawInRect:CGRectMake(minx+(w-size_num.width)/2, miny+8, w, 18) withAttributes:[NSDictionary dictionaryWithObjects:attribute_v forKeys:attribute]]; NSString *letter=txt2; // [t1 drawInRect:CGRectMake(minx, maxy-15, w, 8) withFont:[UIFont boldSystemFontOfSize:8] lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter]; attribute_v=@[[UIColor whiteColor],[UIFont systemFontOfSize:8]]; UIFont *font_letter = [UIFont systemFontOfSize:8]; CGSize size_letter = [letter sizeWithFont:font_letter constrainedToSize:CGSizeMake(150.0f, 1000.0f) lineBreakMode:UILineBreakModeCharacterWrap]; [letter drawInRect:CGRectMake(x+(w-size_letter.width)/2, maxy-15, w, 8) withAttributes:[NSDictionary dictionaryWithObjects:attribute_v forKeys:attribute]]; CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]); CGContextSetLineWidth(context, 1); CGContextAddEllipseInRect(context, frame); //进行绘画 CGContextDrawPath(context, kCGPathStroke); }
试试其它关键字
解锁
同语言下
.
根据生日计算星座
.
精简的实现一个内存池
.
iOS索引搜索核心代码
.
iOS 搜索框
.
文件操作
.
UIWebView 加载本地网页
.
取消导航条对视图的影响
.
利用终端显示 隐藏文件
.
更改导航条背景颜色
.
iOS 字体斜体
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
宝清
贡献的其它代码
(
78
)
.
Java 获取Linux 的IP地址
.
FTP服务器上的文件上传、下载、删除操作
.
监听IE文档加载完成、弹窗、JS弹窗、页面跳转
.
防盗链
.
Hive 典型的中表内数据除重写法
.
判断一个时间段内有多少个周末
.
生成验证码
.
ServiceHelper-Windows服务辅助类
.
IE 6下修复PNG格式的透明度
.
居中对齐并设置固定宽度
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3