LCMenuView简介

2014-11-05  本文已影响62人  HolyCat_猫

简介

筛选功能在慧驾项目中用的比较多,所以抽取出来,以便简化代码,便于维护

类与方法说明

LCMenuView
菜单标题相关,与此次迭代UI相同,以后根据UI的变更进行修改,提供方法和属性如下:
<pre><code>

@property (nonatomic, weak, readonly) UIView *parent;
@property (nonatomic, strong, readonly) UIView *maskView;

@property (nonatomic, assign, readonly) NSInteger popedIndex; // 当前显示菜单index
</code></pre>

LCMenuPopupView
弹出菜单相关,主要封装了菜单的弹出收起动画,提供方法和属性如下:
<pre><code>
// 初始化方法 arrowBtmCenterX是箭头X轴位置

@property (nonatomic, strong, readwrite) UIView *contentView;

@property (nonatomic, assign, readonly) CGFloat arrowBtmCenterX;

// 显示或隐藏内容
@property (nonatomic, assign, getter=isShow) BOOL show;

使用方法

创建UIView子类,封装弹出菜单的内容,本次封装的是LCMenuContentView
<pre><code>
LCMenuContentView *t0 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoMile.count) titles:arrayPopInfoMile selectRow:0];
t0.shopPopViewDelegate = self;
LCMenuPopupView *p0 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoMile.count) ContentView:t0 arrowPosition:53];

NSInteger index = -1;
index = [arrayPopInfoKind indexOfObject:self.stringTitle];
LCMenuContentView *t1 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoKind.count) titles:arrayPopInfoKind selectRow:index];
t1.shopPopViewDelegate = self;
LCMenuPopupView *p1 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoKind.count) ContentView:t1 arrowPosition:160];


LCMenuContentView *t2 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoComment.count) titles:arrayPopInfoComment selectRow:-1];
t2.shopPopViewDelegate = self;
LCMenuPopupView *p2 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoComment.count) ContentView:t2 arrowPosition:320 - 53];

LCMenuView *view = [[LCMenuView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)
                                       segmentWidths:@[@(106), @(108), @(106)]
                                       segmentTitles:@[arrayPopInfoMile[0], self.stringTitle, @"智能"]
                                              popups:@[p0, p1, p2]
                                          parentView:self.view];
[self.view addSubview:view];

</code></pre>

上一篇 下一篇

猜你喜欢

热点阅读