Skip to content

Commit 893cf84

Browse files
committed
mark PopMenu
1 parent 4bde8a5 commit 893cf84

11 files changed

Lines changed: 719 additions & 1 deletion

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@
243243
4E94C4EF1B4B73BB00EB668A /* scan_line@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E94C4EE1B4B73BB00EB668A /* scan_line@2x.png */; };
244244
4E94C4F11B4B75DB00EB668A /* tip_2FA@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E94C4F01B4B75DB00EB668A /* tip_2FA@2x.png */; };
245245
4E94C4F41B4D007600EB668A /* Login2FATipCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E94C4F31B4D007600EB668A /* Login2FATipCell.m */; };
246+
4E94C4FE1B4D2B9300EB668A /* GlowImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E94C4F71B4D2B9300EB668A /* GlowImageView.m */; };
247+
4E94C4FF1B4D2B9300EB668A /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E94C4F91B4D2B9300EB668A /* MenuButton.m */; };
248+
4E94C5001B4D2B9300EB668A /* MenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E94C4FB1B4D2B9300EB668A /* MenuItem.m */; };
249+
4E94C5011B4D2B9300EB668A /* PopMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E94C4FD1B4D2B9300EB668A /* PopMenu.m */; };
246250
4E969CD01AF0EB87005C0CCE /* NSTimer+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E969CCF1AF0EB87005C0CCE /* NSTimer+Common.m */; };
247251
4E96E7BB1A1B25D40037C098 /* DirectoryWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E96E7BA1A1B25D40037C098 /* DirectoryWatcher.m */; };
248252
4E96E7C81A1B46740037C098 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E96E7C71A1B46740037C098 /* QuickLook.framework */; };
@@ -1127,6 +1131,14 @@
11271131
4E94C4F01B4B75DB00EB668A /* tip_2FA@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tip_2FA@2x.png"; sourceTree = "<group>"; };
11281132
4E94C4F21B4D007600EB668A /* Login2FATipCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Login2FATipCell.h; sourceTree = "<group>"; };
11291133
4E94C4F31B4D007600EB668A /* Login2FATipCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Login2FATipCell.m; sourceTree = "<group>"; };
1134+
4E94C4F61B4D2B9300EB668A /* GlowImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlowImageView.h; sourceTree = "<group>"; };
1135+
4E94C4F71B4D2B9300EB668A /* GlowImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GlowImageView.m; sourceTree = "<group>"; };
1136+
4E94C4F81B4D2B9300EB668A /* MenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuButton.h; sourceTree = "<group>"; };
1137+
4E94C4F91B4D2B9300EB668A /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuButton.m; sourceTree = "<group>"; };
1138+
4E94C4FA1B4D2B9300EB668A /* MenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuItem.h; sourceTree = "<group>"; };
1139+
4E94C4FB1B4D2B9300EB668A /* MenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuItem.m; sourceTree = "<group>"; };
1140+
4E94C4FC1B4D2B9300EB668A /* PopMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopMenu.h; sourceTree = "<group>"; };
1141+
4E94C4FD1B4D2B9300EB668A /* PopMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PopMenu.m; sourceTree = "<group>"; };
11301142
4E969CCE1AF0EB87005C0CCE /* NSTimer+Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTimer+Common.h"; sourceTree = "<group>"; };
11311143
4E969CCF1AF0EB87005C0CCE /* NSTimer+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTimer+Common.m"; sourceTree = "<group>"; };
11321144
4E96E7B91A1B25D40037C098 /* DirectoryWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryWatcher.h; sourceTree = "<group>"; };
@@ -2378,6 +2390,21 @@
23782390
path = icon_file_state;
23792391
sourceTree = "<group>";
23802392
};
2393+
4E94C4F51B4D2B9300EB668A /* PopMenu */ = {
2394+
isa = PBXGroup;
2395+
children = (
2396+
4E94C4F61B4D2B9300EB668A /* GlowImageView.h */,
2397+
4E94C4F71B4D2B9300EB668A /* GlowImageView.m */,
2398+
4E94C4F81B4D2B9300EB668A /* MenuButton.h */,
2399+
4E94C4F91B4D2B9300EB668A /* MenuButton.m */,
2400+
4E94C4FA1B4D2B9300EB668A /* MenuItem.h */,
2401+
4E94C4FB1B4D2B9300EB668A /* MenuItem.m */,
2402+
4E94C4FC1B4D2B9300EB668A /* PopMenu.h */,
2403+
4E94C4FD1B4D2B9300EB668A /* PopMenu.m */,
2404+
);
2405+
path = PopMenu;
2406+
sourceTree = "<group>";
2407+
};
23812408
4E96E7C91A1B537E0037C098 /* icon_file */ = {
23822409
isa = PBXGroup;
23832410
children = (
@@ -3501,6 +3528,7 @@
35013528
8EA6D03E19E240C40076D59C /* Vendor */ = {
35023529
isa = PBXGroup;
35033530
children = (
3531+
4E94C4F51B4D2B9300EB668A /* PopMenu */,
35043532
4E09EE061B438AA10053A67F /* KxMenu */,
35053533
4E53EB4C1AF9CC520034FE1C /* RKSwipeBetweenViewControllers */,
35063534
EBDD2E3E1AE7B84D0024B952 /* WMDelLabel */,
@@ -4422,6 +4450,7 @@
44224450
4E5F39021AC951060010515D /* TaskCommentCCell.m in Sources */,
44234451
4ECE8AD91A3943E80021E29C /* UIViewController+DownMenu.m in Sources */,
44244452
8EA6D23819E240C40076D59C /* ProjectTasksView.m in Sources */,
4453+
4E94C5011B4D2B9300EB668A /* PopMenu.m in Sources */,
44254454
8EA6D13019E240C40076D59C /* LikersViewController.m in Sources */,
44264455
8EF643C719FF7E2900F7EEB0 /* TitleValueMoreCell.m in Sources */,
44274456
8EF643C119FF7E2900F7EEB0 /* TaskCommentCell.m in Sources */,
@@ -4487,6 +4516,7 @@
44874516
8E97CE471A0A2DF8006F9AD7 /* AGEmojiKeyBoardView.m in Sources */,
44884517
4E53EB521AFA03990034FE1C /* RKSwipeBetweenViewControllers.m in Sources */,
44894518
8EA6D12C19E240C40076D59C /* EditTopicViewController.m in Sources */,
4519+
4E94C4FE1B4D2B9300EB668A /* GlowImageView.m in Sources */,
44904520
4E24B2681B43D33F004D7989 /* ProjectToChooseListViewController.m in Sources */,
44914521
4EA7F15B1A6D192B00A046BD /* SDWebImageCompat.m in Sources */,
44924522
8EA6D13A19E240C40076D59C /* Project_RootViewController.m in Sources */,
@@ -4577,6 +4607,7 @@
45774607
4ECE8AE11A3943E80021E29C /* UIButton+Common.m in Sources */,
45784608
4ECE8AD81A3943E80021E29C /* UIDownMenuButton.m in Sources */,
45794609
8EA6D14819E240C40076D59C /* UsersViewController.m in Sources */,
4610+
4E94C4FF1B4D2B9300EB668A /* MenuButton.m in Sources */,
45804611
3A3878401AE295970078D5DE /* ResetLabelCell.m in Sources */,
45814612
4EA679201A15AB9F001A0324 /* FileListViewController.m in Sources */,
45824613
8EA6D14119E240C40076D59C /* ValueListViewController.m in Sources */,
@@ -4642,6 +4673,7 @@
46424673
8E59F1031A0120F1009A905F /* CodeFile.m in Sources */,
46434674
4E996BCA1ABA754600C704F1 /* JDStatusBarView.m in Sources */,
46444675
4E4D6A881B1C6E1B00FD2E49 /* MRPRAcceptEditCell.m in Sources */,
4676+
4E94C5001B4D2B9300EB668A /* MenuItem.m in Sources */,
46454677
8EF643AD19FF7E2900F7EEB0 /* TweetMediaItemCCell.m in Sources */,
46464678
3A3878461AE296240078D5DE /* EditLabelHeadCell.m in Sources */,
46474679
8EA6D23519E240C40076D59C /* ProjectListView.m in Sources */,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// GlowImageView.h
3+
// JackFastKit
4+
//
5+
// Created by 曾 宪华 on 14-10-13.
6+
// Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved.
7+
//
8+
9+
// ==========================================
10+
// GlowImageView 菜单按钮 UIView 处理点击事件等
11+
// ==========================================
12+
13+
#import <UIKit/UIKit.h>
14+
15+
@interface GlowImageView : UIButton
16+
17+
/**
18+
* 设置阴影的偏移值(+,+)表示向左下偏移 默认为 (0,0)
19+
*/
20+
@property (nonatomic, assign) CGSize glowOffset;
21+
22+
/**
23+
* 设置阴影的模糊度 默认为: 5
24+
*/
25+
@property (nonatomic, assign) CGFloat glowAmount;
26+
27+
/**
28+
* 设置阴影的颜色 默认为 grayColor 灰色
29+
*/
30+
@property (nonatomic, strong) UIColor *glowColor;
31+
32+
@end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// GlowImageView.m
3+
// JackFastKit
4+
//
5+
// Created by 曾 宪华 on 14-10-13.
6+
// Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved.
7+
//
8+
9+
#import "GlowImageView.h"
10+
11+
12+
13+
@implementation GlowImageView
14+
15+
/**
16+
* 设置阴影的颜色
17+
*/
18+
- (void)setGlowColor:(UIColor *)newGlowColor {
19+
_glowColor = newGlowColor;
20+
if (newGlowColor) {
21+
[self setUpProperty];
22+
}
23+
}
24+
25+
- (instancetype)initWithFrame:(CGRect)frame {
26+
self = [super initWithFrame:frame];
27+
if (self) {
28+
29+
}
30+
return self;
31+
}
32+
33+
/**
34+
* 根据阴影 设置图层 默认属性
35+
*/
36+
- (void)setUpProperty {
37+
self.layer.shadowColor = self.glowColor.CGColor;
38+
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(-5, -5, CGRectGetWidth(self.bounds) + 10, CGRectGetHeight(self.bounds) + 10) cornerRadius:(CGRectGetHeight(self.bounds) + 10) / 2.0].CGPath;
39+
self.layer.shadowOffset = CGSizeMake(0.0, 0.0);
40+
self.layer.shadowOpacity = 0.5;
41+
self.layer.masksToBounds = NO;
42+
}
43+
44+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// MenuButton.h
3+
// JackFastKit
4+
//
5+
// Created by 曾 宪华 on 14-10-13.
6+
// Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved.
7+
//
8+
9+
// ==========================================
10+
// MenuButton 菜单视图 UIView 处理点击事件等
11+
// ==========================================
12+
#import <UIKit/UIKit.h>
13+
14+
@class MenuItem;
15+
16+
typedef void(^DidSelctedItemCompletedBlock)(MenuItem *menuItem);
17+
18+
@interface MenuButton : UIView
19+
20+
/**
21+
* 点击操作
22+
*/
23+
@property (nonatomic, copy) DidSelctedItemCompletedBlock didSelctedItemCompleted;
24+
25+
#pragma mark - init
26+
- (instancetype)initWithFrame:(CGRect)frame menuItem:(MenuItem *)menuItem;
27+
28+
@end
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// MenuButton.m
3+
// JackFastKit
4+
//
5+
// Created by 曾 宪华 on 14-10-13.
6+
// Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved.
7+
//
8+
9+
#import "MenuButton.h"
10+
#import <POP.h>
11+
12+
// Model
13+
#import "MenuItem.h"
14+
15+
// View
16+
#import "GlowImageView.h"
17+
18+
@interface MenuButton ()
19+
20+
@property (nonatomic, strong) GlowImageView *iconImageView;
21+
@property (nonatomic, strong) UILabel *titleLabel;
22+
23+
@property (nonatomic, strong) MenuItem *menuItem;
24+
25+
@end
26+
27+
@implementation MenuButton
28+
29+
- (instancetype)initWithFrame:(CGRect)frame menuItem:(MenuItem *)menuItem {
30+
self = [super initWithFrame:frame];
31+
if (self) {
32+
// Initialization code
33+
self.menuItem = menuItem;
34+
35+
self.iconImageView = [[GlowImageView alloc] initWithFrame:CGRectMake(0, 0, menuItem.iconImage.size.width, menuItem.iconImage.size.height)];
36+
self.iconImageView.userInteractionEnabled = NO;
37+
[self.iconImageView setImage:menuItem.iconImage forState:UIControlStateNormal];
38+
self.iconImageView.glowColor = menuItem.glowColor;
39+
self.iconImageView.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.iconImageView.bounds));
40+
[self addSubview:self.iconImageView];
41+
42+
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.iconImageView.frame), CGRectGetWidth(self.bounds), 35)];
43+
self.titleLabel.textColor = [UIColor whiteColor];
44+
self.titleLabel.backgroundColor = [UIColor clearColor];
45+
self.titleLabel.font = [UIFont systemFontOfSize:14];
46+
self.titleLabel.textAlignment = NSTextAlignmentCenter;
47+
self.titleLabel.text = menuItem.title;
48+
CGPoint center = self.titleLabel.center;
49+
center.x = CGRectGetMidX(self.bounds);
50+
self.titleLabel.center = center;
51+
[self addSubview:self.titleLabel];
52+
}
53+
return self;
54+
}
55+
56+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
57+
// 播放缩放动画
58+
POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation];
59+
scaleAnimation.springBounciness = 20; // value between 0-20
60+
scaleAnimation.springSpeed = 20; // value between 0-20
61+
scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY];
62+
scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.3, 1.3)];
63+
[self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"];
64+
}
65+
66+
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
67+
[self disMissCompleted:NULL];
68+
}
69+
70+
- (void)disMissCompleted:(void(^)(BOOL finished))completed {
71+
POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation];
72+
scaleAnimation.springBounciness = 16; // value between 0-20
73+
scaleAnimation.springSpeed = 14; // value between 0-20
74+
scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY];
75+
scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)];
76+
scaleAnimation.completionBlock = ^(POPAnimation *anim, BOOL finished) {
77+
if (completed) {
78+
completed(finished);
79+
}
80+
};
81+
[self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"];
82+
}
83+
84+
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
85+
// 回调
86+
[self disMissCompleted:^(BOOL finished) {
87+
if (self.didSelctedItemCompleted) {
88+
self.didSelctedItemCompleted(self.menuItem);
89+
}
90+
}];
91+
}
92+
93+
@end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// MenuItem.h
3+
// JackFastKit
4+
//
5+
// Created by 曾 宪华 on 14-10-13.
6+
// Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved.
7+
//
8+
9+
// ==========================================
10+
// MenuItem 菜单元素 数据模型
11+
// ==========================================
12+
13+
#import <Foundation/Foundation.h>
14+
#import <UIKit/UIKit.h>
15+
16+
@interface MenuItem : NSObject
17+
18+
/**
19+
* 标题
20+
*/
21+
@property (nonatomic, copy) NSString *title;
22+
23+
/**
24+
* 配图
25+
*/
26+
@property (nonatomic, strong) UIImage *iconImage;
27+
28+
/**
29+
*
30+
*/
31+
@property (nonatomic, strong) UIColor *glowColor;
32+
33+
/**
34+
* 按钮索引
35+
*/
36+
@property (nonatomic, assign) NSInteger index;
37+
38+
#pragma mark - 初始话 init
39+
40+
- (instancetype)initWithTitle:(NSString *)title
41+
iconName:(NSString *)iconName NS_AVAILABLE_IOS(2_0);
42+
43+
- (instancetype)initWithTitle:(NSString *)title
44+
iconName:(NSString *)iconName
45+
glowColor:(UIColor *)glowColor NS_AVAILABLE_IOS(2_0);
46+
47+
- (instancetype)initWithTitle:(NSString *)title
48+
iconName:(NSString *)iconName
49+
index:(NSInteger)index NS_AVAILABLE_IOS(2_0);
50+
51+
- (instancetype)initWithTitle:(NSString *)title
52+
iconName:(NSString *)iconName
53+
glowColor:(UIColor *)glowColor
54+
index:(NSInteger)index NS_AVAILABLE_IOS(2_0);
55+
56+
+ (instancetype)itemWithTitle:(NSString *)title
57+
iconName:(NSString *)iconName NS_AVAILABLE_IOS(2_0);
58+
59+
+ (instancetype)itemWithTitle:(NSString *)title
60+
iconName:(NSString *)iconName
61+
glowColor:(UIColor *)glowColor NS_AVAILABLE_IOS(2_0);
62+
63+
+ (instancetype)initWithTitle:(NSString *)title
64+
iconName:(NSString *)iconName
65+
index:(NSInteger)index NS_AVAILABLE_IOS(2_0);
66+
67+
+ (instancetype)initWithTitle:(NSString *)title
68+
iconName:(NSString *)iconName
69+
glowColor:(UIColor *)glowColor
70+
index:(NSInteger)index NS_AVAILABLE_IOS(2_0);
71+
72+
@end

0 commit comments

Comments
 (0)