iOS(CoreGraphics)画带箭头的框
来源:互联网 发布:mac谷歌浏览器安装 编辑:程序博客网 时间:2024/04/25 21:16
自己画带箭头的框,需要导入CoreGraphics.framwork库
新建一个集成UIView 的类,对UIView中的drawRect:(CGRect)rect方法重写如下。
绘图操作
//绘制带箭头的矩形
-(void)drawArrowRectangle:(CGRect) frame
{
// 获取当前图形,视图推入堆栈的图形,相当于你所要绘制图形的图纸
CGContextRef ctx =UIGraphicsGetCurrentContext();
// 创建一个新的空图形路径。
CGContextBeginPath(ctx);
//启始位置坐标x,y
CGFloat origin_x = frame.origin.x;
CGFloat origin_y = frame.origin.y;
//第一条线的位置坐标
CGFloat line_1_x = frame.size.width;
CGFloat line_1_y = origin_y;
//第二条线的位置坐标
CGFloat line_2_x = line_1_x;
CGFloat line_2_y = frame.size.height;
//第三条线的位置坐标
CGFloat line_3_x = origin_x + 20;
CGFloat line_3_y = line_2_y;
//尖角的顶点位置坐标
CGFloat line_4_x = line_3_x - 5;
CGFloat line_4_y = line_2_y + 10;
//第五条线位置坐标
CGFloat line_5_x = line_4_x - 5;
CGFloat line_5_y = line_3_y;
//第六条线位置坐标
CGFloat line_6_x = origin_x;
CGFloat line_6_y = line_2_y;
CGContextMoveToPoint(ctx, origin_x, origin_y);
CGContextAddLineToPoint(ctx, line_1_x, line_1_y);
CGContextAddLineToPoint(ctx, line_2_x, line_2_y);
CGContextAddLineToPoint(ctx, line_3_x, line_3_y);
CGContextAddLineToPoint(ctx, line_4_x, line_4_y);
CGContextAddLineToPoint(ctx, line_5_x, line_5_y);
CGContextAddLineToPoint(ctx, line_6_x, line_6_y);
CGContextClosePath(ctx);
UIColor *costomColor = [UIColorcolorWithWhite:0alpha:0.8];
CGContextSetFillColorWithColor(ctx, costomColor.CGColor);
CGContextFillPath(ctx);
}
//重写绘图,调用刚才绘图的方法
-(void)drawRect:(CGRect)rect
{
CGRect frame = rect;
frame.size.height = frame.size.height -20;
rect = frame;
//绘制带箭头的框框
[selfdrawArrowRectangle:rect];
}
- iOS(CoreGraphics)画带箭头的框
- iOS(CoreGraphics)画带箭头的框
- iOS(CoreGraphics)画带箭头的框
- iOS 带箭头的弹出框
- 用Canvas画带箭头的线(包括箭头向内和箭头向外)
- iOS开发的2D绘制--CoreGraphics的简单使用三(画文字和图片)
- java 画带箭头的直线
- Arcgis engine画带箭头的线
- java 画带箭头的直线
- js canvas画带箭头的虚线
- 使用canvas画带箭头的圆环
- 带箭头的直线
- 带箭头的listbox
- 带箭头的DIV
- iOS开发之控件带箭头的弹出窗
- iOS之CoreGraphics使用(1)
- 绘制带箭头的直线
- 绘制带箭头的直线
- java获取cpu、内存、硬盘信息
- dom4j
- poj3648Wedding【2-SAT】输出任意解
- HDU 2141 Can you find it?(二分)
- listview 内部按钮的点击事件
- iOS(CoreGraphics)画带箭头的框
- Java之URLEncoder和URLDecoder类使用小记
- php的正则表达式
- poj 2105
- RSLinx与C#通信错误
- MFC点击按钮,弹出进度条并且自动滚动以及进度条对话框背景色、按钮颜色设置
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
- 代码中设置控件的centerInParent
- javascript设计模式之二——策略模式