Skip to content

Commit

Permalink
FlipView
Browse files Browse the repository at this point in the history
  • Loading branch information
murakami committed Mar 10, 2012
1 parent 2b3304e commit 9ac425e
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 4 deletions.
12 changes: 12 additions & 0 deletions ios/CoreAnimation/CoreAnimation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
563BD9FC150B790D0082F10C /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 563BD9FB150B790D0082F10C /* arrow.png */; };
563BDA04150B9F8A0082F10C /* FlipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 563BDA03150B9F8A0082F10C /* FlipView.m */; };
564265C01507A86700F49E8D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 564265BF1507A86700F49E8D /* UIKit.framework */; };
564265C21507A86700F49E8D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 564265C11507A86700F49E8D /* Foundation.framework */; };
564265C41507A86700F49E8D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 564265C31507A86700F49E8D /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -34,6 +36,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
563BD9FB150B790D0082F10C /* arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = arrow.png; sourceTree = "<group>"; };
563BDA02150B9F8A0082F10C /* FlipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlipView.h; sourceTree = "<group>"; };
563BDA03150B9F8A0082F10C /* FlipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlipView.m; sourceTree = "<group>"; };
564265BB1507A86700F49E8D /* CoreAnimation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreAnimation.app; sourceTree = BUILT_PRODUCTS_DIR; };
564265BF1507A86700F49E8D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
564265C11507A86700F49E8D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -118,6 +123,8 @@
564265D11507A86700F49E8D /* MainStoryboard.storyboard */,
564265FA1507B86500F49E8D /* AnimationBlockView.h */,
564265FB1507B86500F49E8D /* AnimationBlockView.m */,
563BDA02150B9F8A0082F10C /* FlipView.h */,
563BDA03150B9F8A0082F10C /* FlipView.m */,
564265F71507B2BD00F49E8D /* Resources */,
564265C61507A86700F49E8D /* Supporting Files */,
);
Expand Down Expand Up @@ -158,6 +165,7 @@
isa = PBXGroup;
children = (
564265F81507B30700F49E8D /* atmark.png */,
563BD9FB150B790D0082F10C /* arrow.png */,
);
path = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -236,6 +244,7 @@
564265CA1507A86700F49E8D /* InfoPlist.strings in Resources */,
564265D31507A86700F49E8D /* MainStoryboard.storyboard in Resources */,
564265F91507B30700F49E8D /* atmark.png in Resources */,
563BD9FC150B790D0082F10C /* arrow.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -273,6 +282,7 @@
564265CC1507A86700F49E8D /* main.m in Sources */,
564265D01507A86700F49E8D /* AppDelegate.m in Sources */,
564265FC1507B86500F49E8D /* AnimationBlockView.m in Sources */,
563BDA04150B9F8A0082F10C /* FlipView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -442,6 +452,7 @@
564265F01507A86700F49E8D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
564265F11507A86700F49E8D /* Build configuration list for PBXNativeTarget "CoreAnimationTests" */ = {
isa = XCConfigurationList;
Expand All @@ -450,6 +461,7 @@
564265F31507A86700F49E8D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
1 change: 1 addition & 0 deletions ios/CoreAnimation/CoreAnimation/AnimationBlockView.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @implementation AnimationBlockView

- (id)initWithFrame:(CGRect)frame
{
DBGMSG(@"%s", __func__);
self = [super initWithFrame:frame];
if (self) {
// Initialization code
Expand Down
8 changes: 8 additions & 0 deletions ios/CoreAnimation/CoreAnimation/CoreAnimation-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

#ifdef DEBUG
#define DBGMSG(...) NSLog(__VA_ARGS__)
#else /* DEBUG */
#define DBGMSG(...)
#endif /* DEBUG */

/* End Of File */
18 changes: 18 additions & 0 deletions ios/CoreAnimation/CoreAnimation/FlipView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// FlipView.h
// CoreAnimation
//
// Created by 村上 幸雄 on 12/03/10.
// Copyright (c) 2012年 ビッツ有限会社. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface FlipView : UIView

@property (strong, nonatomic) UIImageView *imageView;
@property (assign, nonatomic) BOOL isAtMark;
@property (strong, nonatomic) UIImage *atmarkImage;
@property (strong, nonatomic) UIImage *arrowImage;

@end
77 changes: 77 additions & 0 deletions ios/CoreAnimation/CoreAnimation/FlipView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// FlipView.m
// CoreAnimation
//
// Created by 村上 幸雄 on 12/03/10.
// Copyright (c) 2012年 ビッツ有限会社. All rights reserved.
//

#import "FlipView.h"

@interface FlipView ()
@end

@implementation FlipView

@synthesize imageView = _imageView;
@synthesize isAtMark = _isAtMark;
@synthesize atmarkImage = _atmarkImage;
@synthesize arrowImage = _arrowImage;

- (id)initWithFrame:(CGRect)frame
{
DBGMSG(@"%s", __func__);
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}

- (void)awakeFromNib
{
DBGMSG(@"%s", __func__);
self.isAtMark = YES;
self.atmarkImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"atmark.png" ofType:nil]];
self.arrowImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow.png" ofType:nil]];
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(128.0, 176.0, 64.0, 64.0)];
self.imageView.image = self.atmarkImage;
[self addSubview:self.imageView];
}

- (void)dealloc
{
self.atmarkImage = nil;
self.arrowImage = nil;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.imageView
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
if (self.isAtMark) {
self.isAtMark = NO;
self.imageView.image = self.arrowImage;

}
else {
self.isAtMark = YES;
self.imageView.image = self.atmarkImage;
}
[UIView commitAnimations];
}

@end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 44 additions & 4 deletions ios/CoreAnimation/CoreAnimation/en.lproj/MainStoryboard.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2177" systemVersion="11D50b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="JXb-4Y-NaC">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11D50b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="JXb-4Y-NaC">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<development defaultVersion="4200" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1173"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1179"/>
</dependencies>
<scenes>
<!--Table View Controller - Root View Controller-->
Expand Down Expand Up @@ -35,7 +36,28 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<segue destination="jfW-e2-3Mq" kind="push" id="gky-xC-ihK"/>
<segue destination="jfW-e2-3Mq" kind="push" identifier="animation block" id="vbn-AT-8FS"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="oNs-EB-E7f" style="IBUITableViewCellStyleDefault" id="9h8-6T-FLL">
<rect key="frame" x="0.0" y="44" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="flip view" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" id="oNs-EB-E7f">
<rect key="frame" x="10" y="0.0" width="280" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<segue destination="Arw-lS-LQf" kind="push" identifier="flip view" id="JyF-ZN-jRg"/>
</connections>
</tableViewCell>
</cells>
Expand All @@ -48,6 +70,21 @@
<point key="canvasLocation" x="82" y="42"/>
</scene>
<!--View Controller-->
<scene sceneID="H4n-PU-II3">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="rdh-gT-b4l" userLabel="First Responder" sceneMemberID="firstResponder"/>
<viewController id="Arw-lS-LQf" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="cbh-gn-CRV" customClass="FlipView">
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="Oog-fG-oOJ"/>
</viewController>
</objects>
<point key="canvasLocation" x="557" y="507"/>
</scene>
<!--View Controller-->
<scene sceneID="fz8-F1-1Pn">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="0Do-j4-0GU" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand All @@ -69,7 +106,7 @@
<navigationItem key="navigationItem" id="jdK-f6-dWj"/>
</viewController>
</objects>
<point key="canvasLocation" x="474" y="42"/>
<point key="canvasLocation" x="557" y="-61"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="4hv-kG-RvT">
Expand Down Expand Up @@ -97,6 +134,9 @@
<relationship kind="outlet" name="atMarkImageView" candidateClass="UIImageView"/>
</relationships>
</class>
<class className="FlipView" superclassName="UIView">
<source key="sourceIdentifier" type="project" relativePath="./Classes/FlipView.h"/>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
Expand Down

0 comments on commit 9ac425e

Please sign in to comment.