Added new button types: paused, left triangle, right triangle, up triangle and down triangle

This commit is contained in:
Jianbin LIN
2014-09-29 17:14:44 +02:00
parent 578d44f18d
commit 0b2a2a5633
8 changed files with 162 additions and 18 deletions

View File

@@ -10,29 +10,29 @@
<string>VBFPopFlatButton</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>A9382D58-F924-4E60-8E1E-4F41803E2677</key>
<key>812B8E635CF39CD906DE8FC7A4B95C026D170F6D</key>
<string>ssh://github.com/iBaro/VBFPopFlatButton.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>VBFPopFlatButton.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>A9382D58-F924-4E60-8E1E-4F41803E2677</key>
<key>812B8E635CF39CD906DE8FC7A4B95C026D170F6D</key>
<string>..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/iBaro/VBFPopFlatButton.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>A9382D58-F924-4E60-8E1E-4F41803E2677</string>
<string>812B8E635CF39CD906DE8FC7A4B95C026D170F6D</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>A9382D58-F924-4E60-8E1E-4F41803E2677</string>
<string>812B8E635CF39CD906DE8FC7A4B95C026D170F6D</string>
<key>IDESourceControlWCCName</key>
<string>VBFPopFlatButton</string>
</dict>

59
VBFPopFlatButton/Base.lproj/Main.storyboard Normal file → Executable file
View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</dependencies>
<scenes>
@@ -77,7 +78,7 @@
</connections>
</button>
<button opaque="NO" tag="7" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Crz-wn-x3J">
<rect key="frame" x="97" y="380" width="69" height="30"/>
<rect key="frame" x="139" y="380" width="69" height="30"/>
<state key="normal" title="Download">
<color key="titleColor" red="0.99989169836044312" green="1" blue="0.99988096952438354" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -87,7 +88,7 @@
</connections>
</button>
<button opaque="NO" tag="8" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gif-y1-05R">
<rect key="frame" x="175" y="380" width="40" height="30"/>
<rect key="frame" x="236" y="380" width="40" height="30"/>
<state key="normal" title="Share">
<color key="titleColor" red="0.99989169836044312" green="1" blue="0.99988096952438354" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -126,7 +127,7 @@
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="uXJ-vF-SUV"/>
</connections>
</button>
<button opaque="NO" tag="12" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="311-Fm-Eug">
<button opaque="NO" tag="17" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="311-Fm-Eug">
<rect key="frame" x="131" y="442" width="58" height="30"/>
<state key="normal" title="Random">
<color key="titleColor" red="0.99989169836044312" green="1" blue="0.99988096952438354" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -146,6 +147,56 @@
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="bF4-Go-yFI"/>
</connections>
</button>
<button opaque="NO" tag="12" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zx9-gT-Q52">
<rect key="frame" x="54" y="380" width="52" height="30"/>
<state key="normal" title="Paused">
<color key="titleColor" red="0.99989169840000003" green="1" blue="0.99988096950000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="2NB-oy-QgD"/>
</connections>
</button>
<button opaque="NO" tag="13" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dXI-W3-ew0">
<rect key="frame" x="64" y="256" width="91" height="30"/>
<state key="normal" title="Right triangle">
<color key="titleColor" red="0.99989169840000003" green="1" blue="0.99988096950000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="yhC-lE-EZR"/>
</connections>
</button>
<button opaque="NO" tag="14" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0mW-DV-JXl">
<rect key="frame" x="176" y="256" width="82" height="30"/>
<state key="normal" title="Left triangle">
<color key="titleColor" red="0.99989169840000003" green="1" blue="0.99988096950000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="7J9-38-yaw"/>
</connections>
</button>
<button opaque="NO" tag="15" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UKl-Xl-C7g">
<rect key="frame" x="64" y="231" width="75" height="30"/>
<state key="normal" title="Up triangle">
<color key="titleColor" red="0.99989169840000003" green="1" blue="0.99988096950000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="l2Q-Ei-MpP"/>
</connections>
</button>
<button opaque="NO" tag="16" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VAY-Ff-Rud">
<rect key="frame" x="175" y="231" width="95" height="30"/>
<state key="normal" title="Down triangle">
<color key="titleColor" red="0.99989169840000003" green="1" blue="0.99988096950000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="0Gc-R1-MO9"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.23510167709999999" green="0.62573839249999996" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</view>

View File

@@ -22,7 +22,15 @@ typedef NS_ENUM(NSInteger, DoubleSegmentState) {
doubleSegmentMoreThanState, // >
doubleSegmentUpArrow, // ^
doubleSegmentDownArrow, // Before symol upside-down
doubleSegmentMinusState // --
doubleSegmentMinusState, // --
doubleSegmentSlashState45, // \ /
doubleSegmentBackSlashState45, // /
doubleSegmentSlashState30, // \ /
doubleSegmentBackSlashState30, // /
doubleSegmentSlashState60, // \ /
doubleSegmentBackSlashState60 // /
};
@property (nonatomic) DoubleSegmentState segmentState;

View File

@@ -166,6 +166,31 @@
toValueTop = -M_PI_4 * 3;
toValueBottom = -M_PI_4;
break;
case doubleSegmentSlashState45:
toValueTop = -M_PI_4;
toValueBottom = -M_PI_4;
break;
case doubleSegmentBackSlashState45:
toValueTop = M_PI_4;
toValueBottom = M_PI_4;
break;
case doubleSegmentSlashState30:
toValueTop = -M_PI_2/3;
toValueBottom = -M_PI_2/3;
break;
case doubleSegmentBackSlashState30:
toValueTop = M_PI_2/3;
toValueBottom = M_PI_2/3;
break;
case doubleSegmentSlashState60:
toValueTop = -M_PI/3;
toValueBottom = -M_PI/3;
break;
case doubleSegmentBackSlashState60:
toValueTop = M_PI/3;
toValueBottom = M_PI/3;
break;
default:
break;
}

View File

@@ -22,7 +22,12 @@ typedef NS_ENUM(NSInteger, FlatButtonType) {
buttonShareType,
buttonDownBasicType,
buttonUpBasicType,
buttonDownArrowType
buttonDownArrowType,
buttonPausedType,
buttonRightTriangleType,
buttonLeftTriangleType,
buttonUpTriangleType,
buttonDownTriangleType,
};
typedef NS_ENUM(NSInteger, FlatButtonStyle) {

View File

@@ -207,8 +207,8 @@
secondOriginPoint.x -= hAmount;
break;
case buttonCloseType:
[self.firstSegment animateToState:doubleSegmentLessThanState];
[self.secondSegment animateToState:doubleSegmentMoreThanState];
[self.firstSegment animateToState:doubleSegmentSlashState45];
[self.secondSegment animateToState:doubleSegmentBackSlashState45];
break;
case buttonDefaultType:
[self.firstSegment animateToState:doubleSegmentDefaultState];
@@ -272,6 +272,59 @@
firstOriginPoint.y -= CGRectGetHeight(self.firstSegment.frame)/5;
break;
case buttonPausedType:
[self.firstSegment animateToState:doubleSegmentDefaultState];
[self.secondSegment animateToState:doubleSegmentDefaultState];
CGFloat horizontalAmount = CGRectGetHeight(self.frame)/5;
firstOriginPoint.x -= horizontalAmount;
secondOriginPoint.x += horizontalAmount;
break;
case buttonRightTriangleType:
self.thirdSegment.opacity = 1.0;
[self.firstSegment animateToState:doubleSegmentSlashState60];
[self.secondSegment animateToState:doubleSegmentBackSlashState60];
[self.thirdSegment animateToState:doubleSegmentDefaultState];
firstOriginPoint.y -= self.bounds.size.width * 0.24;
secondOriginPoint.y += self.bounds.size.width * 0.24;
firstOriginPoint.x += self.bounds.size.width/8;
secondOriginPoint.x += self.bounds.size.width/8;
thirdOriginPoint.x -= self.bounds.size.width * 0.30;
break;
case buttonLeftTriangleType:
self.thirdSegment.opacity = 1.0;
[self.firstSegment animateToState:doubleSegmentSlashState60];
[self.secondSegment animateToState:doubleSegmentBackSlashState60];
[self.thirdSegment animateToState:doubleSegmentDefaultState];
firstOriginPoint.y += self.bounds.size.width * 0.24;
secondOriginPoint.y -= self.bounds.size.width * 0.24;
firstOriginPoint.x -= self.bounds.size.width/8;
secondOriginPoint.x -= self.bounds.size.width/8;
thirdOriginPoint.x += self.bounds.size.width * 0.30;
break;
case buttonUpTriangleType:
self.thirdSegment.opacity = 1.0;
[self.firstSegment animateToState:doubleSegmentSlashState30];
[self.secondSegment animateToState:doubleSegmentBackSlashState30];
[self.thirdSegment animateToState:doubleSegmentMinusState];
firstOriginPoint.x += self.bounds.size.width * 0.24;
secondOriginPoint.x -= self.bounds.size.width * 0.24;
firstOriginPoint.y -= self.bounds.size.width/8;
secondOriginPoint.y -= self.bounds.size.width/8;
thirdOriginPoint.y += self.bounds.size.width * 0.30;
break;
case buttonDownTriangleType:
self.thirdSegment.opacity = 1.0;
[self.firstSegment animateToState:doubleSegmentSlashState30];
[self.secondSegment animateToState:doubleSegmentBackSlashState30];
[self.thirdSegment animateToState:doubleSegmentMinusState];
firstOriginPoint.x -= self.bounds.size.width * 0.24;
secondOriginPoint.x += self.bounds.size.width * 0.24;
firstOriginPoint.y += self.bounds.size.width/8;
secondOriginPoint.y += self.bounds.size.width/8;
thirdOriginPoint.y -= self.bounds.size.width * 0.30;
break;
default:
break;
}

0
VBFPopFlatButton/ViewController.h Normal file → Executable file
View File

12
VBFPopFlatButton/ViewController.m Normal file → Executable file
View File

@@ -10,6 +10,8 @@
#import "UIColor+FlatColors.h"
#import "VBFPopFlatButton.h"
#define NUM_BUTTON_STATES 17
@interface ViewController ()
@property (nonatomic, strong) VBFPopFlatButton *flatRoundedButton;
@property (nonatomic, strong) VBFPopFlatButton *flatPlainButton;
@@ -48,23 +50,23 @@
}
- (IBAction)buttonPressed:(UIButton *)sender {
if (sender.tag != 12) {
if (sender.tag != NUM_BUTTON_STATES) {
[self.flatRoundedButton animateToType:sender.tag];
[self.flatPlainButton animateToType:sender.tag];
} else {
[self.flatRoundedButton animateToType:arc4random()%12];
[self.flatPlainButton animateToType:arc4random()%12];
[self.flatRoundedButton animateToType:arc4random() % NUM_BUTTON_STATES];
[self.flatPlainButton animateToType:arc4random() % NUM_BUTTON_STATES];
}
}
- (void) flatRoundedButtonPressed {
NSLog(@"Button pressed");
[self.flatRoundedButton animateToType:arc4random()%12];
[self.flatRoundedButton animateToType:arc4random() % NUM_BUTTON_STATES];
}
- (void) flatPlainButtonPressed {
NSLog(@"Button pressed");
[self.flatPlainButton animateToType:arc4random()%12];
[self.flatPlainButton animateToType:arc4random() % NUM_BUTTON_STATES];
}
@end