Skip to content

Commit 2ec87a3

Browse files
committed
test
1 parent b85fade commit 2ec87a3

File tree

4 files changed

+85
-8
lines changed

4 files changed

+85
-8
lines changed

acordionTest.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
942A565E192DB0C10020F9F5 /* imageTest.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 942A565D192DB0C10020F9F5 /* imageTest.jpg */; };
1011
946EDBB4192DAC0C004D6FEA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946EDBB3192DAC0C004D6FEA /* Foundation.framework */; };
1112
946EDBB6192DAC0C004D6FEA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946EDBB5192DAC0C004D6FEA /* CoreGraphics.framework */; };
1213
946EDBB8192DAC0C004D6FEA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 946EDBB7192DAC0C004D6FEA /* UIKit.framework */; };
@@ -34,6 +35,7 @@
3435
/* End PBXContainerItemProxy section */
3536

3637
/* Begin PBXFileReference section */
38+
942A565D192DB0C10020F9F5 /* imageTest.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = imageTest.jpg; sourceTree = "<group>"; };
3739
946EDBB0192DAC0C004D6FEA /* acordionTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = acordionTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
3840
946EDBB3192DAC0C004D6FEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3941
946EDBB5192DAC0C004D6FEA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -112,6 +114,7 @@
112114
946EDBB9192DAC0C004D6FEA /* acordionTest */ = {
113115
isa = PBXGroup;
114116
children = (
117+
942A565D192DB0C10020F9F5 /* imageTest.jpg */,
115118
946EDBC2192DAC0C004D6FEA /* AppDelegate.h */,
116119
946EDBC3192DAC0C004D6FEA /* AppDelegate.m */,
117120
946EDBC5192DAC0C004D6FEA /* Main.storyboard */,
@@ -229,6 +232,7 @@
229232
buildActionMask = 2147483647;
230233
files = (
231234
946EDBCC192DAC0C004D6FEA /* Images.xcassets in Resources */,
235+
942A565E192DB0C10020F9F5 /* imageTest.jpg in Resources */,
232236
946EDBBE192DAC0C004D6FEA /* InfoPlist.strings in Resources */,
233237
946EDBC7192DAC0C004D6FEA /* Main.storyboard in Resources */,
234238
);
@@ -460,6 +464,7 @@
460464
946EDBE4192DAC0D004D6FEA /* Release */,
461465
);
462466
defaultConfigurationIsVisible = 0;
467+
defaultConfigurationName = Release;
463468
};
464469
946EDBE5192DAC0D004D6FEA /* Build configuration list for PBXNativeTarget "acordionTestTests" */ = {
465470
isa = XCConfigurationList;
@@ -468,6 +473,7 @@
468473
946EDBE7192DAC0D004D6FEA /* Release */,
469474
);
470475
defaultConfigurationIsVisible = 0;
476+
defaultConfigurationName = Release;
471477
};
472478
/* End XCConfigurationList section */
473479
};

acordionTest/Base.lproj/Main.storyboard

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4510" systemVersion="13C1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3676"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
55
</dependencies>
66
<scenes>
7-
<!--class Prefix:identifier View Controller-->
7+
<!--View Controller-->
88
<scene sceneID="ufC-wZ-h7g">
99
<objects>
1010
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
11+
<layoutGuides>
12+
<viewControllerLayoutGuide type="top" id="Dwq-Nc-Ibd"/>
13+
<viewControllerLayoutGuide type="bottom" id="THA-S5-fo9"/>
14+
</layoutGuides>
1115
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
1216
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
1317
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
18+
<subviews>
19+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WYS-Aw-jFk">
20+
<rect key="frame" x="36" y="116" width="249" height="335"/>
21+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
22+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
23+
</view>
24+
</subviews>
1425
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
1526
</view>
27+
<connections>
28+
<outlet property="containerView" destination="WYS-Aw-jFk" id="fa9-1W-sHI"/>
29+
</connections>
1630
</viewController>
1731
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
1832
</objects>

acordionTest/ViewController.m

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,80 @@
77
//
88

99
#import "ViewController.h"
10+
#import <QuartzCore/QuartzCore.h>
1011

1112
@interface ViewController ()
12-
13+
@property (weak, nonatomic) IBOutlet UIView *containerView;
14+
@property (nonatomic) CALayer *top;
15+
@property (nonatomic) CALayer *bottom;
16+
@property (nonatomic) BOOL open;
1317
@end
1418

1519
@implementation ViewController
1620

1721
- (void)viewDidLoad
1822
{
1923
[super viewDidLoad];
20-
// Do any additional setup after loading the view, typically from a nib.
24+
25+
self.view.backgroundColor = [UIColor blackColor];
26+
27+
CGSize viewSize = self.containerView.bounds.size;
28+
self.top = [CALayer layer];
29+
self.bottom = [CALayer layer];
30+
self.top.anchorPoint = CGPointMake(0.5, 0.5);
31+
self.bottom.anchorPoint = CGPointMake(0.5, 0.5);
32+
self.top.position = CGPointMake(viewSize.width/2.0, viewSize.height/2.0);
33+
self.bottom.position = CGPointMake(viewSize.width/2.0, viewSize.height/2.0);
34+
self.top.bounds = CGRectMake(0, 0, viewSize.width, viewSize.height);
35+
self.bottom.bounds = CGRectMake(0, 0, viewSize.width, viewSize.height);
36+
self.top.backgroundColor = [UIColor whiteColor].CGColor;
37+
self.bottom.backgroundColor = [UIColor whiteColor].CGColor;
38+
39+
self.top.transform = makePerspectiveTransform();
40+
self.bottom.transform = makePerspectiveTransform();
41+
42+
[self.containerView.layer addSublayer:self.top];
43+
[self.containerView.layer addSublayer:self.bottom];
44+
45+
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];
46+
[self.containerView addGestureRecognizer:tap];
47+
48+
self.open = NO;
49+
}
50+
51+
52+
- (void)handleTap {
53+
if (!self.open) {
54+
UIImage *image = [UIImage imageNamed:@"imageTest.jpg"];
55+
56+
CGImageRef imgRef = image.CGImage;
57+
self.top.contents = (__bridge id)imgRef;
58+
self.bottom.contents = (__bridge id)imgRef;
59+
self.top.contentsRect = CGRectMake(0.0, 0.0, 1.0, 0.5);
60+
self.bottom.contentsRect = CGRectMake(0.0, 0.5, 1.0, 0.5);
61+
62+
self.top.transform = CATransform3DScale(self.top.transform, 0.95, 0.95, 0.95);
63+
self.bottom.transform = CATransform3DScale(self.bottom.transform, 0.95, 0.95, 0.95);
64+
65+
self.top.transform = CATransform3DRotate(self.top.transform, M_PI_2, 1.0, 0.0, 0.0);
66+
self.bottom.transform = CATransform3DRotate(self.bottom.transform, -M_PI_2, 1.0, 0.0, 0.0);
67+
68+
self.top.transform = CATransform3DTranslate(self.top.transform, 0.0, 0.0, 0.0);
69+
self.bottom.transform = CATransform3DTranslate(self.bottom.transform, 0.0, 0.0, 0.0);
70+
} else {
71+
self.top.transform = CATransform3DIdentity;
72+
self.bottom.transform = CATransform3DIdentity;
73+
self.top.transform = makePerspectiveTransform();
74+
self.bottom.transform = makePerspectiveTransform();
75+
}
76+
self.open = !self.open;
2177
}
2278

23-
- (void)didReceiveMemoryWarning
79+
CATransform3D makePerspectiveTransform()
2480
{
25-
[super didReceiveMemoryWarning];
26-
// Dispose of any resources that can be recreated.
81+
CATransform3D transform = CATransform3DIdentity;
82+
transform.m34 = 1.0 / -2000;
83+
return transform;
2784
}
2885

2986
@end

acordionTest/imageTest.jpg

575 KB
Loading

0 commit comments

Comments
 (0)