如何在导航栏的标题项上添加专辑选择器视图
Posted
技术标签:
【中文标题】如何在导航栏的标题项上添加专辑选择器视图【英文标题】:How To Add album selector view on Navigation bar's title item 【发布时间】:2016-07-30 08:43:53 【问题描述】:我想添加此功能,即选择导航栏的标题,然后找到显示弹出类型的视图,该视图显示的是另一个视图。 facebook 的照片选择器中发生的事情。如何编程我的导航栏标题以显示这个新视图?
【问题讨论】:
【参考方案1】:你应该设计 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];
【讨论】:
以上是关于如何在导航栏的标题项上添加专辑选择器视图的主要内容,如果未能解决你的问题,请参考以下文章