首次加载提示框

如图:


需要在页面首次加载时候显示,提醒一下用户,后面加载就不需要展示了

这个框是画出来的,单独创建一个继承自UIView的类,下面是代码
一、

#import 

二、

- (void)drawRect:(CGRect)rect {
    CGRect frame = rect;
    frame.size.height = frame.size.height - 20;
    rect = frame;
    //绘制带箭头的框框
    [self drawArrowRectangle:rect];
}

- (void)drawArrowRectangle:(CGRect) frame {
    
    CGFloat corners = 8.0;
    
    // 获取当前图形,视图推入堆栈的图形,相当于你所要绘制图形的图纸
    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 + frame.size.width/2+5;//20;
    CGFloat line_3_y = line_2_y;
    //尖角的顶点位置坐标(尖角右边线)
    CGFloat line_4_x = line_3_x - 5;
    CGFloat line_4_y = line_3_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);
    CGContextAddArcToPoint(ctx, line_1_x, line_1_y, line_1_x, line_2_y, corners);
    CGContextAddLineToPoint(ctx, line_1_x, line_1_y);
    CGContextAddArcToPoint(ctx, line_2_x, line_2_y, line_3_x, line_3_y, corners);
    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);
    CGContextAddArcToPoint(ctx, line_6_x, line_6_y, origin_x, origin_y, corners);
    CGContextAddLineToPoint(ctx, line_6_x, line_6_y);
    CGContextAddArcToPoint(ctx, origin_x, origin_y, line_1_x, line_1_y, corners);
    CGContextClosePath(ctx);
    UIColor *costomColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
    CGContextSetFillColorWithColor(ctx, costomColor.CGColor);
    
    CGContextFillPath(ctx);
}

三、只第一次加载页面显示,通过NSUserDefaults来实现

你可能感兴趣的:(首次加载提示框)