mirror of
https://github.com/wu736139669/ASH_Manager.git
synced 2026-08-05 05:55:23 +00:00
init
This commit is contained in:
+26
-9
@@ -1,11 +1,28 @@
|
||||
# Build and Release Folders
|
||||
bin/
|
||||
bin-debug/
|
||||
bin-release/
|
||||
build/
|
||||
**/build
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
.DS_Store
|
||||
*.DS_Store
|
||||
**/.DS_Store
|
||||
**/xcuserdata
|
||||
**/DerivedData
|
||||
|
||||
# Other files and folders
|
||||
.settings/
|
||||
# emacs backup files
|
||||
*~
|
||||
|
||||
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
|
||||
# should NOT be excluded as they contain compiler settings and other important
|
||||
# information for Eclipse / Flash Builder.
|
||||
# CocoaPods
|
||||
Pods
|
||||
Podfile.lock
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
|
||||
s.name = "ASH_Manager"
|
||||
s.version = "0.0.1"
|
||||
s.summary = "A short description of ASH_Manager."
|
||||
|
||||
|
||||
s.description = <<-DESC
|
||||
DESC
|
||||
|
||||
s.homepage = "http://EXAMPLE/ASH_Manager"
|
||||
|
||||
|
||||
|
||||
s.license = { :type => "MIT", :file => "LICENSE" }
|
||||
|
||||
|
||||
|
||||
s.author = { "wushenghua" => "wushenghua@linggan.com" }
|
||||
|
||||
s.platform = :ios, "7.0"
|
||||
|
||||
|
||||
|
||||
s.source = { :git => "http://EXAMPLE/ASH_Manager.git", :tag => "0.0.1" }
|
||||
|
||||
|
||||
s.source_files = "ASH_Manager/*.{h,m}"
|
||||
|
||||
|
||||
s.requires_arc = true
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// HobbyTagView.h
|
||||
// xmfish
|
||||
//
|
||||
// Created by xmfish on 15/10/27.
|
||||
// Copyright © 2015年 小鱼网. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class HobbyViewModel;
|
||||
@interface HobbyTagView : UIView
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame withData:(HobbyViewModel*)hobbyViewModel;
|
||||
@end
|
||||
@@ -0,0 +1,424 @@
|
||||
//
|
||||
// HobbyTagView.m
|
||||
// xmfish
|
||||
//
|
||||
// Created by xmfish on 15/10/27.
|
||||
// Copyright © 2015年 小鱼网. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HobbyTagView.h"
|
||||
|
||||
|
||||
@interface PositonUIButton : UIButton
|
||||
|
||||
@property (assign,nonatomic) int row;
|
||||
@property (assign,nonatomic) int column;
|
||||
@property (assign,nonatomic) BOOL isShowMore;
|
||||
-(void)show;
|
||||
@end
|
||||
|
||||
@implementation PositonUIButton
|
||||
-(void)show
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
self.frame = CGRectMake(frame.origin.x+frame.size.width, frame.origin.y+frame.size.height, 0, 0);
|
||||
[UIView animateKeyframesWithDuration:0.4 delay:0 options:UIViewKeyframeAnimationOptionLayoutSubviews animations:^{
|
||||
self.frame = frame;
|
||||
} completion:nil];
|
||||
}
|
||||
@end
|
||||
CGFloat BtnWidth = 80.0;
|
||||
CGFloat BtnHeight = 30.0;
|
||||
CGFloat XOrigin = 60.0;
|
||||
CGFloat YOrigin = 50.0;
|
||||
@implementation HobbyTagView
|
||||
{
|
||||
HobbyViewModel* _hobbyViewModel;
|
||||
UIScrollView* _scrollView;
|
||||
NSMutableArray* _btnArr;
|
||||
NSArray* titleArr;
|
||||
}
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
-(id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame withData:(HobbyViewModel *)hobbyViewModel
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_hobbyViewModel = hobbyViewModel;
|
||||
_btnArr = [[NSMutableArray alloc] init];
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
titleArr = @[@"美食",@"好玩的",@"游戏",@"健身",@"美国",@"食谱",@"出国旅游",@"书单",@"海报",@"明星",@"音乐"];
|
||||
XOrigin = (([[UIScreen mainScreen] bounds].size.width)-3*(BtnWidth))/2.0+20;
|
||||
[self initView];
|
||||
[self setButton];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setBtn:(UIButton*)button
|
||||
{
|
||||
[self setButton];
|
||||
}
|
||||
-(void)setButton
|
||||
{
|
||||
|
||||
NSArray* xOffSetArr = [NSArray arrayWithObjects:@1,@3,@0,@2,@4, nil];
|
||||
|
||||
for (int i=0; i<20; i++) {
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = i;
|
||||
btn.isShowMore = NO;
|
||||
int row = i/5;
|
||||
int col = i%5;
|
||||
|
||||
row = row*2;
|
||||
row = row + (col<2?0:1);
|
||||
|
||||
int xOffset = [(NSNumber*)xOffSetArr[col] intValue];
|
||||
|
||||
btn.center = CGPointMake(xOffset*50+XOrigin, row*40+YOrigin);
|
||||
|
||||
btn.row = row;
|
||||
switch (col) {
|
||||
case 0:
|
||||
btn.column = 0;
|
||||
break;
|
||||
case 1:
|
||||
btn.column = 1;
|
||||
break;
|
||||
case 2:
|
||||
btn.column = 0;
|
||||
break;
|
||||
case 3:
|
||||
btn.column = 1;
|
||||
break;
|
||||
case 4:
|
||||
btn.column = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(_btnArr.count > row)
|
||||
{
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableArray* array = [[NSMutableArray alloc] init];
|
||||
[array addObject:btn];
|
||||
[_btnArr addObject:array];
|
||||
}
|
||||
[_scrollView addSubview:btn];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)initView
|
||||
{
|
||||
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
|
||||
_scrollView.showsHorizontalScrollIndicator = NO;
|
||||
_scrollView.showsVerticalScrollIndicator = NO;
|
||||
[_scrollView setContentSize:_scrollView.bounds.size];
|
||||
_scrollView.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:_scrollView];
|
||||
|
||||
_btnArr = [[NSMutableArray alloc] init];
|
||||
|
||||
}
|
||||
|
||||
-(void)addLeftBtn:(PositonUIButton*)button
|
||||
{
|
||||
if (!button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int row = button.row;
|
||||
int column = button.column;
|
||||
BOOL shouldReSet = NO;
|
||||
CGRect frame = button.frame;
|
||||
frame.origin.x -= (BtnWidth+20);
|
||||
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = btn.tag+1;
|
||||
btn.row = button.row;
|
||||
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (btn.column < column)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x -= (BtnWidth+20);
|
||||
|
||||
btn.frame = tempFrame;
|
||||
if (tempFrame.origin.x < 0)
|
||||
{
|
||||
shouldReSet = YES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (frame.origin.x < 0 || shouldReSet)
|
||||
{
|
||||
|
||||
CGSize size = _scrollView.contentSize;
|
||||
size.width += (BtnWidth+20);
|
||||
_scrollView.contentSize = size;
|
||||
for (NSMutableArray* arr in _btnArr)
|
||||
{
|
||||
for (PositonUIButton* btn in arr)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x += (BtnWidth+20);
|
||||
btn.frame = tempFrame;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
frame = button.frame;
|
||||
frame.origin.x -= (BtnWidth+20);
|
||||
btn.frame = frame;
|
||||
for (PositonUIButton* button in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (button.column >= column)
|
||||
{
|
||||
button.column++;
|
||||
}
|
||||
}
|
||||
btn.column = column;
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
[_scrollView addSubview:btn];
|
||||
[btn show];
|
||||
}
|
||||
-(void)addRight:(PositonUIButton*)button
|
||||
{
|
||||
if (!button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int row = button.row;
|
||||
int column = button.column;
|
||||
BOOL shouldReSet = NO;
|
||||
CGRect frame = button.frame;
|
||||
frame.origin.x += (BtnWidth+20);
|
||||
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = btn.tag+1;
|
||||
btn.row = button.row;
|
||||
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (btn.column > column)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x += (BtnWidth+20);
|
||||
|
||||
btn.frame = tempFrame;
|
||||
if (tempFrame.origin.x+BtnWidth > _scrollView.contentSize.width)
|
||||
{
|
||||
shouldReSet = YES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (frame.origin.x+BtnWidth > _scrollView.contentSize.width || shouldReSet)
|
||||
{
|
||||
|
||||
CGSize size = _scrollView.contentSize;
|
||||
size.width += (BtnWidth+20);
|
||||
_scrollView.contentSize = size;
|
||||
|
||||
}
|
||||
|
||||
frame = button.frame;
|
||||
frame.origin.x += (BtnWidth+20);
|
||||
btn.frame = frame;
|
||||
for (PositonUIButton* button in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (button.column > column)
|
||||
{
|
||||
button.column++;
|
||||
}
|
||||
}
|
||||
btn.column = column+1;
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
[_scrollView addSubview:btn];
|
||||
[btn show];
|
||||
}
|
||||
-(void)addTopBtn:(PositonUIButton*)button withType:(int)type
|
||||
{
|
||||
int row = button.row;
|
||||
row--;
|
||||
if (row < 0)
|
||||
{
|
||||
[self addBottomBtn:button withType:2];
|
||||
return;
|
||||
}
|
||||
PositonUIButton* resultBtn = nil;
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
|
||||
if (btn.frame.origin.x > button.frame.origin.x)
|
||||
{
|
||||
resultBtn = btn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resultBtn)
|
||||
{
|
||||
resultBtn = [[_btnArr objectAtIndex:row] lastObject];
|
||||
}
|
||||
if (type == 1)
|
||||
{
|
||||
[self addLeftBtn:resultBtn];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self addRight:resultBtn];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)addBottomBtn:(PositonUIButton*)button withType:(int)type
|
||||
{
|
||||
int row = button.row;
|
||||
row++;
|
||||
if (row >= _btnArr.count)
|
||||
{
|
||||
[self addTopBtn:button withType:2];
|
||||
return;
|
||||
}
|
||||
PositonUIButton* resultBtn = nil;
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
|
||||
if (btn.frame.origin.x > button.frame.origin.x)
|
||||
{
|
||||
resultBtn = btn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resultBtn)
|
||||
{
|
||||
resultBtn = [[_btnArr objectAtIndex:row] lastObject];
|
||||
}
|
||||
if (type == 1)
|
||||
{
|
||||
[self addLeftBtn:resultBtn];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self addRight:resultBtn];
|
||||
}
|
||||
}
|
||||
-(void)btnClick:(PositonUIButton*)button
|
||||
{
|
||||
|
||||
if (!button.selected)
|
||||
{
|
||||
[button setSelected:YES];
|
||||
button.backgroundColor = [UIColor colorWithCGColor:button.layer.borderColor] ;
|
||||
}
|
||||
else
|
||||
{
|
||||
[button setSelected:NO];
|
||||
button.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
if (button.isShowMore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
button.isShowMore = YES;
|
||||
int random = arc4random()%4+1;
|
||||
switch (random) {
|
||||
case 1:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
[self addTopBtn:button withType:1];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
[self addTopBtn:button withType:1];
|
||||
[self addBottomBtn:button withType:1];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(PositonUIButton*)buttonWithData:(NSObject*)infoViewModel
|
||||
{
|
||||
PositonUIButton* button = [PositonUIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
button.frame = CGRectMake(0, 0, BtnWidth, BtnHeight);
|
||||
button.layer.masksToBounds = YES;
|
||||
button.layer.cornerRadius = 15.0;
|
||||
button.layer.borderWidth = 1.0;
|
||||
button.selected = NO;
|
||||
button.titleLabel.adjustsFontSizeToFitWidth = YES;
|
||||
button.titleLabel.minimumScaleFactor = 0.8;
|
||||
[button.titleLabel setFont:[UIFont systemFontOfSize:12.0]];
|
||||
|
||||
[button setTintColor:[UIColor purpleColor]];
|
||||
|
||||
UIColor* color = [UIColor purpleColor];
|
||||
int colorV = arc4random()%4;
|
||||
if (colorV==0) {
|
||||
color = [UIColor brownColor];
|
||||
}else if (colorV==1){
|
||||
color = [UIColor blueColor];
|
||||
}else if (colorV==2){
|
||||
color = [UIColor orangeColor];
|
||||
}else if (colorV==3)
|
||||
{
|
||||
color = [UIColor purpleColor];
|
||||
}
|
||||
int value = arc4random()%11;
|
||||
[button setTitle:[titleArr objectAtIndex:value] forState:UIControlStateNormal];
|
||||
[button setTitleColor:color forState:UIControlStateNormal];
|
||||
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
|
||||
button.layer.borderColor = [color CGColor];
|
||||
return button;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,312 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
A9BFA24D1C507ABB00970274 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BFA24C1C507ABB00970274 /* main.m */; };
|
||||
A9BFA2501C507ABB00970274 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BFA24F1C507ABB00970274 /* AppDelegate.m */; };
|
||||
A9BFA2531C507ABC00970274 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BFA2521C507ABC00970274 /* ViewController.m */; };
|
||||
A9BFA2561C507ABC00970274 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9BFA2541C507ABC00970274 /* Main.storyboard */; };
|
||||
A9BFA2581C507ABC00970274 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9BFA2571C507ABC00970274 /* Assets.xcassets */; };
|
||||
A9BFA25B1C507ABC00970274 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9BFA2591C507ABC00970274 /* LaunchScreen.storyboard */; };
|
||||
A9BFA2641C507B1700970274 /* HobbyTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BFA2631C507B1700970274 /* HobbyTagView.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
A9BFA2481C507ABB00970274 /* ASH_ManagerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ASH_ManagerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A9BFA24C1C507ABB00970274 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
A9BFA24E1C507ABB00970274 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
A9BFA24F1C507ABB00970274 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
A9BFA2511C507ABB00970274 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
A9BFA2521C507ABC00970274 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
A9BFA2551C507ABC00970274 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
A9BFA2571C507ABC00970274 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
A9BFA25A1C507ABC00970274 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
A9BFA25C1C507ABC00970274 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
A9BFA2621C507B1700970274 /* HobbyTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HobbyTagView.h; sourceTree = "<group>"; };
|
||||
A9BFA2631C507B1700970274 /* HobbyTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HobbyTagView.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
A9BFA2451C507ABB00970274 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
A9BFA23F1C507ABB00970274 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9BFA24A1C507ABB00970274 /* ASH_ManagerDemo */,
|
||||
A9BFA2491C507ABB00970274 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9BFA2491C507ABB00970274 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9BFA2481C507ABB00970274 /* ASH_ManagerDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9BFA24A1C507ABB00970274 /* ASH_ManagerDemo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9BFA2621C507B1700970274 /* HobbyTagView.h */,
|
||||
A9BFA2631C507B1700970274 /* HobbyTagView.m */,
|
||||
A9BFA24E1C507ABB00970274 /* AppDelegate.h */,
|
||||
A9BFA24F1C507ABB00970274 /* AppDelegate.m */,
|
||||
A9BFA2511C507ABB00970274 /* ViewController.h */,
|
||||
A9BFA2521C507ABC00970274 /* ViewController.m */,
|
||||
A9BFA2541C507ABC00970274 /* Main.storyboard */,
|
||||
A9BFA2571C507ABC00970274 /* Assets.xcassets */,
|
||||
A9BFA2591C507ABC00970274 /* LaunchScreen.storyboard */,
|
||||
A9BFA25C1C507ABC00970274 /* Info.plist */,
|
||||
A9BFA24B1C507ABB00970274 /* Supporting Files */,
|
||||
);
|
||||
path = ASH_ManagerDemo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9BFA24B1C507ABB00970274 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9BFA24C1C507ABB00970274 /* main.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
A9BFA2471C507ABB00970274 /* ASH_ManagerDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = A9BFA25F1C507ABC00970274 /* Build configuration list for PBXNativeTarget "ASH_ManagerDemo" */;
|
||||
buildPhases = (
|
||||
A9BFA2441C507ABB00970274 /* Sources */,
|
||||
A9BFA2451C507ABB00970274 /* Frameworks */,
|
||||
A9BFA2461C507ABB00970274 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = ASH_ManagerDemo;
|
||||
productName = ASH_ManagerDemo;
|
||||
productReference = A9BFA2481C507ABB00970274 /* ASH_ManagerDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
A9BFA2401C507ABB00970274 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0720;
|
||||
ORGANIZATIONNAME = ash;
|
||||
TargetAttributes = {
|
||||
A9BFA2471C507ABB00970274 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = A9BFA2431C507ABB00970274 /* Build configuration list for PBXProject "ASH_ManagerDemo" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = A9BFA23F1C507ABB00970274;
|
||||
productRefGroup = A9BFA2491C507ABB00970274 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
A9BFA2471C507ABB00970274 /* ASH_ManagerDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
A9BFA2461C507ABB00970274 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A9BFA25B1C507ABC00970274 /* LaunchScreen.storyboard in Resources */,
|
||||
A9BFA2581C507ABC00970274 /* Assets.xcassets in Resources */,
|
||||
A9BFA2561C507ABC00970274 /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
A9BFA2441C507ABB00970274 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A9BFA2641C507B1700970274 /* HobbyTagView.m in Sources */,
|
||||
A9BFA2531C507ABC00970274 /* ViewController.m in Sources */,
|
||||
A9BFA2501C507ABB00970274 /* AppDelegate.m in Sources */,
|
||||
A9BFA24D1C507ABB00970274 /* main.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
A9BFA2541C507ABC00970274 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A9BFA2551C507ABC00970274 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9BFA2591C507ABC00970274 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A9BFA25A1C507ABC00970274 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
A9BFA25D1C507ABC00970274 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A9BFA25E1C507ABC00970274 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
A9BFA2601C507ABC00970274 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = ASH_ManagerDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "ash.ASH-ManagerDemo";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A9BFA2611C507ABC00970274 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = ASH_ManagerDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "ash.ASH-ManagerDemo";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
A9BFA2431C507ABB00970274 /* Build configuration list for PBXProject "ASH_ManagerDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A9BFA25D1C507ABC00970274 /* Debug */,
|
||||
A9BFA25E1C507ABC00970274 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
A9BFA25F1C507ABC00970274 /* Build configuration list for PBXNativeTarget "ASH_ManagerDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A9BFA2601C507ABC00970274 /* Debug */,
|
||||
A9BFA2611C507ABC00970274 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = A9BFA2401C507ABB00970274 /* Project object */;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ASH_ManagerDemo.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// AppDelegate.h
|
||||
// ASH_ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 16/1/21.
|
||||
// Copyright © 2016年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// ASH_ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 16/1/21.
|
||||
// Copyright © 2016年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// HobbyTagView.h
|
||||
// xmfish
|
||||
//
|
||||
// Created by xmfish on 15/10/27.
|
||||
// Copyright © 2015年 小鱼网. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class HobbyViewModel;
|
||||
@interface HobbyTagView : UIView
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame withData:(HobbyViewModel*)hobbyViewModel;
|
||||
@end
|
||||
@@ -0,0 +1,424 @@
|
||||
//
|
||||
// HobbyTagView.m
|
||||
// xmfish
|
||||
//
|
||||
// Created by xmfish on 15/10/27.
|
||||
// Copyright © 2015年 小鱼网. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HobbyTagView.h"
|
||||
|
||||
|
||||
@interface PositonUIButton : UIButton
|
||||
|
||||
@property (assign,nonatomic) int row;
|
||||
@property (assign,nonatomic) int column;
|
||||
@property (assign,nonatomic) BOOL isShowMore;
|
||||
-(void)show;
|
||||
@end
|
||||
|
||||
@implementation PositonUIButton
|
||||
-(void)show
|
||||
{
|
||||
CGRect frame = self.frame;
|
||||
self.frame = CGRectMake(frame.origin.x+frame.size.width, frame.origin.y+frame.size.height, 0, 0);
|
||||
[UIView animateKeyframesWithDuration:0.4 delay:0 options:UIViewKeyframeAnimationOptionLayoutSubviews animations:^{
|
||||
self.frame = frame;
|
||||
} completion:nil];
|
||||
}
|
||||
@end
|
||||
CGFloat BtnWidth = 80.0;
|
||||
CGFloat BtnHeight = 30.0;
|
||||
CGFloat XOrigin = 60.0;
|
||||
CGFloat YOrigin = 50.0;
|
||||
@implementation HobbyTagView
|
||||
{
|
||||
HobbyViewModel* _hobbyViewModel;
|
||||
UIScrollView* _scrollView;
|
||||
NSMutableArray* _btnArr;
|
||||
NSArray* titleArr;
|
||||
}
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
-(id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame withData:(HobbyViewModel *)hobbyViewModel
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_hobbyViewModel = hobbyViewModel;
|
||||
_btnArr = [[NSMutableArray alloc] init];
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
titleArr = @[@"美食",@"好玩的",@"游戏",@"健身",@"美国",@"食谱",@"出国旅游",@"书单",@"海报",@"明星",@"音乐"];
|
||||
XOrigin = (([[UIScreen mainScreen] bounds].size.width)-3*(BtnWidth))/2.0+20;
|
||||
[self initView];
|
||||
[self setButton];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setBtn:(UIButton*)button
|
||||
{
|
||||
[self setButton];
|
||||
}
|
||||
-(void)setButton
|
||||
{
|
||||
|
||||
NSArray* xOffSetArr = [NSArray arrayWithObjects:@1,@3,@0,@2,@4, nil];
|
||||
|
||||
for (int i=0; i<20; i++) {
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = i;
|
||||
btn.isShowMore = NO;
|
||||
int row = i/5;
|
||||
int col = i%5;
|
||||
|
||||
row = row*2;
|
||||
row = row + (col<2?0:1);
|
||||
|
||||
int xOffset = [(NSNumber*)xOffSetArr[col] intValue];
|
||||
|
||||
btn.center = CGPointMake(xOffset*50+XOrigin, row*40+YOrigin);
|
||||
|
||||
btn.row = row;
|
||||
switch (col) {
|
||||
case 0:
|
||||
btn.column = 0;
|
||||
break;
|
||||
case 1:
|
||||
btn.column = 1;
|
||||
break;
|
||||
case 2:
|
||||
btn.column = 0;
|
||||
break;
|
||||
case 3:
|
||||
btn.column = 1;
|
||||
break;
|
||||
case 4:
|
||||
btn.column = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(_btnArr.count > row)
|
||||
{
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableArray* array = [[NSMutableArray alloc] init];
|
||||
[array addObject:btn];
|
||||
[_btnArr addObject:array];
|
||||
}
|
||||
[_scrollView addSubview:btn];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)initView
|
||||
{
|
||||
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
|
||||
_scrollView.showsHorizontalScrollIndicator = NO;
|
||||
_scrollView.showsVerticalScrollIndicator = NO;
|
||||
[_scrollView setContentSize:_scrollView.bounds.size];
|
||||
_scrollView.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:_scrollView];
|
||||
|
||||
_btnArr = [[NSMutableArray alloc] init];
|
||||
|
||||
}
|
||||
|
||||
-(void)addLeftBtn:(PositonUIButton*)button
|
||||
{
|
||||
if (!button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int row = button.row;
|
||||
int column = button.column;
|
||||
BOOL shouldReSet = NO;
|
||||
CGRect frame = button.frame;
|
||||
frame.origin.x -= (BtnWidth+20);
|
||||
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = btn.tag+1;
|
||||
btn.row = button.row;
|
||||
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (btn.column < column)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x -= (BtnWidth+20);
|
||||
|
||||
btn.frame = tempFrame;
|
||||
if (tempFrame.origin.x < 0)
|
||||
{
|
||||
shouldReSet = YES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (frame.origin.x < 0 || shouldReSet)
|
||||
{
|
||||
|
||||
CGSize size = _scrollView.contentSize;
|
||||
size.width += (BtnWidth+20);
|
||||
_scrollView.contentSize = size;
|
||||
for (NSMutableArray* arr in _btnArr)
|
||||
{
|
||||
for (PositonUIButton* btn in arr)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x += (BtnWidth+20);
|
||||
btn.frame = tempFrame;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
frame = button.frame;
|
||||
frame.origin.x -= (BtnWidth+20);
|
||||
btn.frame = frame;
|
||||
for (PositonUIButton* button in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (button.column >= column)
|
||||
{
|
||||
button.column++;
|
||||
}
|
||||
}
|
||||
btn.column = column;
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
[_scrollView addSubview:btn];
|
||||
[btn show];
|
||||
}
|
||||
-(void)addRight:(PositonUIButton*)button
|
||||
{
|
||||
if (!button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int row = button.row;
|
||||
int column = button.column;
|
||||
BOOL shouldReSet = NO;
|
||||
CGRect frame = button.frame;
|
||||
frame.origin.x += (BtnWidth+20);
|
||||
|
||||
PositonUIButton* btn = [self buttonWithData:nil];
|
||||
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.tag = btn.tag+1;
|
||||
btn.row = button.row;
|
||||
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (btn.column > column)
|
||||
{
|
||||
CGRect tempFrame = btn.frame;
|
||||
tempFrame.origin.x += (BtnWidth+20);
|
||||
|
||||
btn.frame = tempFrame;
|
||||
if (tempFrame.origin.x+BtnWidth > _scrollView.contentSize.width)
|
||||
{
|
||||
shouldReSet = YES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (frame.origin.x+BtnWidth > _scrollView.contentSize.width || shouldReSet)
|
||||
{
|
||||
|
||||
CGSize size = _scrollView.contentSize;
|
||||
size.width += (BtnWidth+20);
|
||||
_scrollView.contentSize = size;
|
||||
|
||||
}
|
||||
|
||||
frame = button.frame;
|
||||
frame.origin.x += (BtnWidth+20);
|
||||
btn.frame = frame;
|
||||
for (PositonUIButton* button in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
if (button.column > column)
|
||||
{
|
||||
button.column++;
|
||||
}
|
||||
}
|
||||
btn.column = column+1;
|
||||
NSMutableArray* array = [_btnArr objectAtIndex:row];
|
||||
[array addObject:btn];
|
||||
[_scrollView addSubview:btn];
|
||||
[btn show];
|
||||
}
|
||||
-(void)addTopBtn:(PositonUIButton*)button withType:(int)type
|
||||
{
|
||||
int row = button.row;
|
||||
row--;
|
||||
if (row < 0)
|
||||
{
|
||||
[self addBottomBtn:button withType:2];
|
||||
return;
|
||||
}
|
||||
PositonUIButton* resultBtn = nil;
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
|
||||
if (btn.frame.origin.x > button.frame.origin.x)
|
||||
{
|
||||
resultBtn = btn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resultBtn)
|
||||
{
|
||||
resultBtn = [[_btnArr objectAtIndex:row] lastObject];
|
||||
}
|
||||
if (type == 1)
|
||||
{
|
||||
[self addLeftBtn:resultBtn];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self addRight:resultBtn];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)addBottomBtn:(PositonUIButton*)button withType:(int)type
|
||||
{
|
||||
int row = button.row;
|
||||
row++;
|
||||
if (row >= _btnArr.count)
|
||||
{
|
||||
[self addTopBtn:button withType:2];
|
||||
return;
|
||||
}
|
||||
PositonUIButton* resultBtn = nil;
|
||||
for (PositonUIButton* btn in [_btnArr objectAtIndex:row])
|
||||
{
|
||||
|
||||
if (btn.frame.origin.x > button.frame.origin.x)
|
||||
{
|
||||
resultBtn = btn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resultBtn)
|
||||
{
|
||||
resultBtn = [[_btnArr objectAtIndex:row] lastObject];
|
||||
}
|
||||
if (type == 1)
|
||||
{
|
||||
[self addLeftBtn:resultBtn];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self addRight:resultBtn];
|
||||
}
|
||||
}
|
||||
-(void)btnClick:(PositonUIButton*)button
|
||||
{
|
||||
|
||||
if (!button.selected)
|
||||
{
|
||||
[button setSelected:YES];
|
||||
button.backgroundColor = [UIColor colorWithCGColor:button.layer.borderColor] ;
|
||||
}
|
||||
else
|
||||
{
|
||||
[button setSelected:NO];
|
||||
button.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
if (button.isShowMore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
button.isShowMore = YES;
|
||||
int random = arc4random()%4+1;
|
||||
switch (random) {
|
||||
case 1:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
[self addTopBtn:button withType:1];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
[self addLeftBtn:button];
|
||||
[self addRight:button];
|
||||
[self addTopBtn:button withType:1];
|
||||
[self addBottomBtn:button withType:1];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(PositonUIButton*)buttonWithData:(NSObject*)infoViewModel
|
||||
{
|
||||
PositonUIButton* button = [PositonUIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
button.frame = CGRectMake(0, 0, BtnWidth, BtnHeight);
|
||||
button.layer.masksToBounds = YES;
|
||||
button.layer.cornerRadius = 15.0;
|
||||
button.layer.borderWidth = 1.0;
|
||||
button.selected = NO;
|
||||
button.titleLabel.adjustsFontSizeToFitWidth = YES;
|
||||
button.titleLabel.minimumScaleFactor = 0.8;
|
||||
[button.titleLabel setFont:[UIFont systemFontOfSize:12.0]];
|
||||
|
||||
[button setTintColor:[UIColor purpleColor]];
|
||||
|
||||
UIColor* color = [UIColor purpleColor];
|
||||
int colorV = arc4random()%4;
|
||||
if (colorV==0) {
|
||||
color = [UIColor brownColor];
|
||||
}else if (colorV==1){
|
||||
color = [UIColor blueColor];
|
||||
}else if (colorV==2){
|
||||
color = [UIColor orangeColor];
|
||||
}else if (colorV==3)
|
||||
{
|
||||
color = [UIColor purpleColor];
|
||||
}
|
||||
int value = arc4random()%11;
|
||||
[button setTitle:[titleArr objectAtIndex:value] forState:UIControlStateNormal];
|
||||
[button setTitleColor:color forState:UIControlStateNormal];
|
||||
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
|
||||
button.layer.borderColor = [color CGColor];
|
||||
return button;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// ViewController.h
|
||||
// ASH_ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 16/1/21.
|
||||
// Copyright © 2016年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// ViewController.m
|
||||
// ASH_ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 16/1/21.
|
||||
// Copyright © 2016年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// main.m
|
||||
// ASH_ManagerDemo
|
||||
//
|
||||
// Created by xmfish on 16/1/21.
|
||||
// Copyright © 2016年 ash. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user