Skip to content

Commit 6262d0f

Browse files
author
HirokiUmatani
committed
add project file
1 parent 784e47d commit 6262d0f

File tree

17 files changed

+1017
-0
lines changed

17 files changed

+1017
-0
lines changed

PEAR-ZoomingView-iOS/ZoomingView.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ZoomingView.h
3+
// ZoomingView
4+
//
5+
// Created by hirokiumatani on 2015/12/30.
6+
// Copyright © 2015年 hirokiumatani. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
@protocol ZoomingViewDelegate <NSObject>
11+
- (void)touchView:(UIView *)view;
12+
@end
13+
@interface ZoomingView : UIView
14+
@property (nonatomic,assign) id <ZoomingViewDelegate> delegate;
15+
@property (nonatomic,assign) NSInteger topMargin;
16+
@property (nonatomic,assign) NSInteger bottomMargin;
17+
@property (nonatomic,assign) NSInteger leftMargin;
18+
@property (nonatomic,assign) NSInteger rightMargin;
19+
@property (nonatomic,assign) BOOL isShadow;
20+
@end

PEAR-ZoomingView-iOS/ZoomingView.m

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//
2+
// ZoomingView.m
3+
// ZoomingView
4+
//
5+
// Created by hirokiumatani on 2015/12/30.
6+
// Copyright © 2015年 hirokiumatani. All rights reserved.
7+
//
8+
9+
#import "ZoomingView.h"
10+
#import <QuartzCore/QuartzCore.h>
11+
@interface ZoomingView()
12+
@property (nonatomic,assign) BOOL isZoom;
13+
@property (nonatomic,assign) CGRect defaultRect;
14+
@end
15+
16+
@implementation ZoomingView
17+
18+
19+
#pragma mark - shadow
20+
- (void)setIsShadow:(BOOL)isShadow
21+
{
22+
_isShadow = isShadow;
23+
if (!_isShadow)
24+
{
25+
[self noShadow];
26+
}
27+
else
28+
{
29+
[self showShadow];
30+
}
31+
}
32+
33+
- (void)noShadow
34+
{
35+
self.layer.shadowOpacity = 0.0;
36+
self.layer.shadowOffset = CGSizeMake(0,0);
37+
}
38+
- (void)showShadow
39+
{
40+
if (_isShadow)
41+
{
42+
self.layer.shadowOpacity = 0.8;
43+
self.layer.shadowOffset = CGSizeMake(0,8);
44+
}
45+
}
46+
- (void)hideShadow
47+
{
48+
if (_isShadow)
49+
{
50+
self.layer.shadowOpacity = 0.5;
51+
self.layer.shadowOffset = CGSizeMake(0,5);
52+
}
53+
}
54+
55+
#pragma mark - zoom
56+
- (void)defaultView
57+
{
58+
[UIView animateWithDuration:0.6
59+
animations:^
60+
{
61+
self.frame = CGRectMake(_defaultRect.origin.x,
62+
_defaultRect.origin.y,
63+
_defaultRect.size.width,
64+
_defaultRect.size.height);
65+
}];
66+
_isZoom = NO;
67+
}
68+
69+
- (void)zoomingView
70+
{
71+
_defaultRect = self.frame;
72+
[UIView animateWithDuration:0.6
73+
animations:^
74+
{
75+
self.frame = CGRectMake(0+_leftMargin,
76+
0+_topMargin,
77+
[UIScreen mainScreen].bounds.size.width
78+
-_leftMargin
79+
-_rightMargin,
80+
[UIScreen mainScreen].bounds.size.height
81+
-_topMargin
82+
-_bottomMargin);
83+
}];
84+
_isZoom = YES;
85+
}
86+
#pragma mark - touch
87+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
88+
{
89+
[self hideShadow];
90+
[_delegate touchView:self];
91+
}
92+
93+
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
94+
{
95+
[self showShadow];
96+
if (_isZoom)
97+
{
98+
[self defaultView];
99+
}
100+
else
101+
{
102+
[self zoomingView];
103+
104+
}
105+
}
106+
@end

0 commit comments

Comments
 (0)