如何在导航栏的标题项上添加专辑选择器视图
How To Add album selector view on Navigation bar's title item
我想添加这个功能,选择我的导航栏的标题,然后找到显示弹出类型的视图,显示另一个视图。 Facebook 的照片选择器中发生的事情。如何对我的导航栏标题进行编程以显示此新视图?
您应该设计 UIView 的自定义 class 并设置以下代码:
#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];
}
我想添加这个功能,选择我的导航栏的标题,然后找到显示弹出类型的视图,显示另一个视图。 Facebook 的照片选择器中发生的事情。如何对我的导航栏标题进行编程以显示此新视图?
您应该设计 UIView 的自定义 class 并设置以下代码:
#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];
}