如何在导航栏的标题项上添加专辑选择器视图

时间:2016-07-30 08:43:53

标签: objective-c uinavigationcontroller uitoolbar

我想添加选择导航栏标题的功能,然后查找显示另一个视图的弹出式视图。 Facebook的照片选择器中发生的事情。如何设置导航栏的标题以显示此新视图?emphasized text

1 个答案:

答案 0 :(得分:0)

您应该设计UIView的自定义类并设置如下代码:

#import "popoverView.h"

@implementation popoverView
- (void)drawRect:(CGRect)rect {

    self.layer.cornerRadius=6.0;
    CGFloat margian=20;
    [self addpathAtPoint:CGPointMake(margian, margian) andEndPoint:CGPointMake(sqrtf(margian*margian+margian*margian), 0.0)];

    [self addpathAtPoint:CGPointMake(sqrtf(margian*margian+margian*margian), 0.0) andEndPoint:CGPointMake(2*margian, margian)];

    [self addpathAtPoint:CGPointMake(2*margian, margian) andEndPoint:CGPointMake(rect.size.width-2*margian, margian)];

    [self addCurveToPoint:CGPointMake(rect.size.width-2*margian, margian) endPoint:CGPointMake(rect.size.width-margian, 2*margian) controlPoint1:CGPointMake(rect.size.width-margian, margian) controlPoint2:CGPointMake(rect.size.width-margian, margian)];

    [self addpathAtPoint:CGPointMake(rect.size.width-margian, 2*margian) andEndPoint:CGPointMake(rect.size.width-margian, rect.size.height-2*margian)];

    [self addCurveToPoint:CGPointMake(rect.size.width-margian, rect.size.height-2*margian) endPoint:CGPointMake(rect.size.width-2*margian, rect.size.height-margian) controlPoint1:CGPointMake(rect.size.width-margian, rect.size.height-margian) controlPoint2:CGPointMake(rect.size.width-margian, rect.size.height-margian)];

    [self addpathAtPoint:CGPointMake(rect.size.width-2*margian, rect.size.height-margian) andEndPoint:CGPointMake(2*margian,rect.size.height-margian)];

    [self addCurveToPoint:CGPointMake(2*margian,rect.size.height-margian) endPoint:CGPointMake(margian,rect.size.height-2*margian) controlPoint1:CGPointMake(margian, rect.size.height-margian) controlPoint2:CGPointMake(margian, rect.size.height-margian)];

    [self addpathAtPoint:CGPointMake(margian,rect.size.height-2*margian) andEndPoint:CGPointMake(margian,margian)];
   }

-(void)addpathAtPoint:(CGPoint)startPoint andEndPoint:(CGPoint)endPoint{
    UIBezierPath *path=[UIBezierPath bezierPath];
    path.lineWidth=3.0;
    [path moveToPoint:startPoint];
    [path addLineToPoint:endPoint];
    [[UIColor blackColor] setStroke];
    [path stroke];
    [path closePath];
}

-(void)addCurveToPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
{
    UIBezierPath *path=[UIBezierPath bezierPath];
    path.lineWidth=3.0;
    [path moveToPoint:startPoint];
    [path addCurveToPoint:endPoint  controlPoint1:controlPoint1 controlPoint2:controlPoint2];
    [[UIColor blackColor]setStroke];
    [path stroke];

}