这里的圆角的对话框 我指的是类似安卓的.9.png那样的圆角的对话框,就是这个样子的。
分解出来就是一个实心的圆角矩形加一个三角形,外面用直线描边,里面写一些居中悬浮的字符串而已。
1.画圆角矩形 假设x1,y1为右下角的点
let rx:CGFloat =4 //圆角弧度
CGContextSetFillColorWithColor(context, UIColor(red: 248/255, green:248/255, blue:248/255, alpha:1).CGColor)//设置画笔颜色
CGContextMoveToPoint(context, x1, y1 - rx); // 右下角
CGContextAddArcToPoint(context, x1, y1, x2, y1, rx); // 右下角度-左下角
CGContextAddArcToPoint(context, x2, y1, x2, y2, rx); // 左下角-左上角
CGContextAddArcToPoint(context, x2, y2, x1, y2, rx); //左上角-右上角
CGContextAddArcToPoint(context, x1, y2, x1, y1, rx); //右上角-