├── .gitignore ├── LICENSE ├── LNChevronView.h ├── LNChevronView.m ├── LNChevronViewExample ├── LNChevronViewExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── LNChevronViewExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── Main.storyboard │ ├── Info.plist │ ├── LNChevronViewExample-Bridging-Header.h │ └── ViewController.swift ├── README.md └── Supplements ├── Screenshot.png └── chevron.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Leo Natan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LNChevronView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LNChevronView.h 3 | // LNChevronViewExample 4 | // 5 | // Created by Leo Natan on 16/9/16. 6 | // Copyright © 2016 Leo Natan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, LNChevronViewState) { 14 | LNChevronViewStateUp = -1, 15 | LNChevronViewStateFlat = 0, 16 | LNChevronViewStateDown = 1 17 | }; 18 | 19 | @interface LNChevronView : UIView 20 | 21 | @property (nonatomic, assign) LNChevronViewState state; 22 | @property (nonatomic, strong, null_resettable) UIColor* color; 23 | @property (nonatomic, assign) CGFloat width; 24 | @property (nonatomic, assign) NSTimeInterval animationDuration; 25 | 26 | - (void)setState:(LNChevronViewState)state animated:(BOOL)animated; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /LNChevronView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LNChevronView.m 3 | // LNChevronViewExample 4 | // 5 | // Created by Leo Natan on 16/9/16. 6 | // Copyright © 2016 Leo Natan. All rights reserved. 7 | // 8 | 9 | #import "LNChevronView.h" 10 | 11 | static const CGFloat _LNChevronDefaultWidth = 4.67; 12 | static const CGFloat _LNChevronAngleCoefficient = 42.5714286; 13 | static const NSTimeInterval _LNChevronDefaultAnimationDuration = 0.3; 14 | 15 | IB_DESIGNABLE 16 | @interface LNChevronView (Inspectable) 17 | 18 | @property (nonatomic, assign) IBInspectable NSInteger chevronState; 19 | @property (nonatomic, strong, null_resettable) IBInspectable UIColor* color; 20 | @property (nonatomic, assign) IBInspectable CGFloat width; 21 | 22 | @end 23 | 24 | @implementation LNChevronView 25 | { 26 | UIView* _leftView; 27 | UIView* _rightView; 28 | 29 | LNChevronViewState _pendingState; 30 | } 31 | 32 | - (instancetype)initWithFrame:(CGRect)frame 33 | { 34 | self = [super initWithFrame:frame]; 35 | [self _commonInit]; 36 | return self; 37 | } 38 | 39 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 40 | { 41 | self = [super initWithCoder:aDecoder]; 42 | [self _commonInit]; 43 | return self; 44 | } 45 | 46 | - (void)_commonInit 47 | { 48 | self.color = [UIColor lightGrayColor]; 49 | self.width = _LNChevronDefaultWidth; 50 | self.animationDuration = _LNChevronDefaultAnimationDuration; 51 | 52 | self.userInteractionEnabled = NO; 53 | } 54 | 55 | - (void)layoutSubviews 56 | { 57 | [super layoutSubviews]; 58 | 59 | if(_leftView == nil) 60 | { 61 | _leftView = [[UIView alloc] initWithFrame:CGRectZero]; 62 | _leftView.backgroundColor = self.color; 63 | _rightView = [[UIView alloc] initWithFrame:CGRectZero]; 64 | _rightView.backgroundColor = self.color; 65 | 66 | [self addSubview:_leftView]; 67 | [self addSubview:_rightView]; 68 | } 69 | 70 | CGRect leftFrame, rightFrame; 71 | CGRectDivide(self.bounds, &leftFrame, &rightFrame, self.bounds.size.width * 0.5, CGRectMinXEdge); 72 | rightFrame.size.height = leftFrame.size.height = self.width; 73 | 74 | CGFloat angle = self.bounds.size.height / self.bounds.size.width * _LNChevronAngleCoefficient; 75 | CGFloat dx = leftFrame.size.width * (1 - cos(angle * M_PI / 180.0)) / 2.0; 76 | 77 | leftFrame = CGRectOffset(leftFrame, self.width / 2 + dx - 0.75, 0.0); 78 | rightFrame = CGRectOffset(rightFrame, -(self.width / 2) - dx + 0.75, 0.0); 79 | 80 | _leftView.bounds = leftFrame; 81 | _rightView.bounds = rightFrame; 82 | _leftView.center = CGPointMake(CGRectGetMidX(leftFrame), CGRectGetMidY(self.bounds)); 83 | _rightView.center = CGPointMake(CGRectGetMidX(rightFrame), CGRectGetMidY(self.bounds)); 84 | 85 | _leftView.layer.cornerRadius = self.width / 2.0; 86 | _rightView.layer.cornerRadius = self.width / 2.0; 87 | 88 | if(_pendingState != 0) 89 | { 90 | [self setState:_pendingState]; 91 | _pendingState = 0; 92 | } 93 | } 94 | 95 | - (void)setChevronState:(NSInteger)state 96 | { 97 | [self setState:state]; 98 | } 99 | 100 | - (void)setState:(LNChevronViewState)state 101 | { 102 | [self setState:state animated:NO]; 103 | } 104 | 105 | - (void)setState:(LNChevronViewState)state animated:(BOOL)animated 106 | { 107 | if(state > 1) 108 | { 109 | state = 1; 110 | } 111 | if(state < -1) 112 | { 113 | state = -1; 114 | } 115 | 116 | if(state == _state) 117 | { 118 | return; 119 | } 120 | 121 | if(_leftView == nil) 122 | { 123 | _pendingState = state; 124 | return; 125 | } 126 | 127 | _state = state; 128 | 129 | CGFloat angle = self.bounds.size.height / self.bounds.size.width * _LNChevronAngleCoefficient; 130 | void (^transition)(void) = ^() { 131 | self->_leftView.transform = CGAffineTransformMakeRotation(-state * angle * M_PI / 180.0); 132 | self->_rightView.transform = CGAffineTransformMakeRotation(state * angle * M_PI / 180.0); 133 | }; 134 | 135 | if(animated == NO) 136 | { 137 | [UIView performWithoutAnimation:transition]; 138 | } 139 | else 140 | { 141 | [UIView animateWithDuration:_animationDuration animations:transition]; 142 | } 143 | } 144 | 145 | - (void)setColor:(UIColor *)color 146 | { 147 | if(color == nil) 148 | { 149 | color = [UIColor lightGrayColor]; 150 | } 151 | 152 | _color = color; 153 | 154 | _leftView.backgroundColor = color; 155 | _rightView.backgroundColor = color; 156 | } 157 | 158 | - (void)setWidth:(CGFloat)width 159 | { 160 | _width = width; 161 | 162 | [self setNeedsLayout]; 163 | } 164 | 165 | #if TARGET_INTERFACE_BUILDER 166 | - (void)prepareForInterfaceBuilder 167 | { 168 | 169 | } 170 | #endif 171 | 172 | @end 173 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 39974D361D8BF66500110310 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39974D351D8BF66500110310 /* AppDelegate.swift */; }; 11 | 39974D381D8BF66500110310 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39974D371D8BF66500110310 /* ViewController.swift */; }; 12 | 39974D3B1D8BF66500110310 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 39974D391D8BF66500110310 /* Main.storyboard */; }; 13 | 39974D3D1D8BF66500110310 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 39974D3C1D8BF66500110310 /* Assets.xcassets */; }; 14 | 39974D4C1D8C199600110310 /* LNChevronView.m in Sources */ = {isa = PBXBuildFile; fileRef = 39974D4B1D8C199600110310 /* LNChevronView.m */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 39974D321D8BF66500110310 /* LNChevronViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LNChevronViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 39974D351D8BF66500110310 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | 39974D371D8BF66500110310 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | 39974D3A1D8BF66500110310 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 22 | 39974D3C1D8BF66500110310 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 39974D411D8BF66500110310 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 39974D491D8C199600110310 /* LNChevronViewExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LNChevronViewExample-Bridging-Header.h"; sourceTree = ""; }; 25 | 39974D4A1D8C199600110310 /* LNChevronView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LNChevronView.h; path = ../LNChevronView.h; sourceTree = SOURCE_ROOT; }; 26 | 39974D4B1D8C199600110310 /* LNChevronView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LNChevronView.m; path = ../LNChevronView.m; sourceTree = SOURCE_ROOT; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 39974D2F1D8BF66500110310 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 39974D291D8BF66500110310 = { 41 | isa = PBXGroup; 42 | children = ( 43 | 39974D341D8BF66500110310 /* LNChevronViewExample */, 44 | 39974D331D8BF66500110310 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 39974D331D8BF66500110310 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 39974D321D8BF66500110310 /* LNChevronViewExample.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 39974D341D8BF66500110310 /* LNChevronViewExample */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 39974D351D8BF66500110310 /* AppDelegate.swift */, 60 | 39974D371D8BF66500110310 /* ViewController.swift */, 61 | 39974D391D8BF66500110310 /* Main.storyboard */, 62 | 39974D3C1D8BF66500110310 /* Assets.xcassets */, 63 | 39974D411D8BF66500110310 /* Info.plist */, 64 | 39974D491D8C199600110310 /* LNChevronViewExample-Bridging-Header.h */, 65 | 39974D4A1D8C199600110310 /* LNChevronView.h */, 66 | 39974D4B1D8C199600110310 /* LNChevronView.m */, 67 | ); 68 | path = LNChevronViewExample; 69 | sourceTree = ""; 70 | }; 71 | /* End PBXGroup section */ 72 | 73 | /* Begin PBXNativeTarget section */ 74 | 39974D311D8BF66500110310 /* LNChevronViewExample */ = { 75 | isa = PBXNativeTarget; 76 | buildConfigurationList = 39974D441D8BF66500110310 /* Build configuration list for PBXNativeTarget "LNChevronViewExample" */; 77 | buildPhases = ( 78 | 39974D2E1D8BF66500110310 /* Sources */, 79 | 39974D2F1D8BF66500110310 /* Frameworks */, 80 | 39974D301D8BF66500110310 /* Resources */, 81 | ); 82 | buildRules = ( 83 | ); 84 | dependencies = ( 85 | ); 86 | name = LNChevronViewExample; 87 | productName = LNChevronViewExample; 88 | productReference = 39974D321D8BF66500110310 /* LNChevronViewExample.app */; 89 | productType = "com.apple.product-type.application"; 90 | }; 91 | /* End PBXNativeTarget section */ 92 | 93 | /* Begin PBXProject section */ 94 | 39974D2A1D8BF66500110310 /* Project object */ = { 95 | isa = PBXProject; 96 | attributes = { 97 | LastSwiftUpdateCheck = 0800; 98 | LastUpgradeCheck = 1250; 99 | ORGANIZATIONNAME = "Leo Natan"; 100 | TargetAttributes = { 101 | 39974D311D8BF66500110310 = { 102 | CreatedOnToolsVersion = 8.0; 103 | DevelopmentTeam = S9QFG2VH2E; 104 | LastSwiftMigration = 0800; 105 | ProvisioningStyle = Automatic; 106 | }; 107 | }; 108 | }; 109 | buildConfigurationList = 39974D2D1D8BF66500110310 /* Build configuration list for PBXProject "LNChevronViewExample" */; 110 | compatibilityVersion = "Xcode 3.2"; 111 | developmentRegion = en; 112 | hasScannedForEncodings = 0; 113 | knownRegions = ( 114 | en, 115 | Base, 116 | ); 117 | mainGroup = 39974D291D8BF66500110310; 118 | productRefGroup = 39974D331D8BF66500110310 /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | 39974D311D8BF66500110310 /* LNChevronViewExample */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | 39974D301D8BF66500110310 /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | 39974D3D1D8BF66500110310 /* Assets.xcassets in Resources */, 133 | 39974D3B1D8BF66500110310 /* Main.storyboard in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | 39974D2E1D8BF66500110310 /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 39974D4C1D8C199600110310 /* LNChevronView.m in Sources */, 145 | 39974D381D8BF66500110310 /* ViewController.swift in Sources */, 146 | 39974D361D8BF66500110310 /* AppDelegate.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin PBXVariantGroup section */ 153 | 39974D391D8BF66500110310 /* Main.storyboard */ = { 154 | isa = PBXVariantGroup; 155 | children = ( 156 | 39974D3A1D8BF66500110310 /* Base */, 157 | ); 158 | name = Main.storyboard; 159 | sourceTree = ""; 160 | }; 161 | /* End PBXVariantGroup section */ 162 | 163 | /* Begin XCBuildConfiguration section */ 164 | 39974D421D8BF66500110310 /* Debug */ = { 165 | isa = XCBuildConfiguration; 166 | buildSettings = { 167 | ALWAYS_SEARCH_USER_PATHS = NO; 168 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 169 | CLANG_ANALYZER_NONNULL = YES; 170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 171 | CLANG_CXX_LIBRARY = "libc++"; 172 | CLANG_ENABLE_MODULES = YES; 173 | CLANG_ENABLE_OBJC_ARC = YES; 174 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 175 | CLANG_WARN_BOOL_CONVERSION = YES; 176 | CLANG_WARN_COMMA = YES; 177 | CLANG_WARN_CONSTANT_CONVERSION = YES; 178 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 181 | CLANG_WARN_EMPTY_BODY = YES; 182 | CLANG_WARN_ENUM_CONVERSION = YES; 183 | CLANG_WARN_INFINITE_RECURSION = YES; 184 | CLANG_WARN_INT_CONVERSION = YES; 185 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 186 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 187 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 188 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 189 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 190 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 191 | CLANG_WARN_STRICT_PROTOTYPES = YES; 192 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 193 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 194 | CLANG_WARN_UNREACHABLE_CODE = YES; 195 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 196 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 197 | COPY_PHASE_STRIP = NO; 198 | DEBUG_INFORMATION_FORMAT = dwarf; 199 | ENABLE_STRICT_OBJC_MSGSEND = YES; 200 | ENABLE_TESTABILITY = YES; 201 | GCC_C_LANGUAGE_STANDARD = gnu99; 202 | GCC_DYNAMIC_NO_PIC = NO; 203 | GCC_NO_COMMON_BLOCKS = YES; 204 | GCC_OPTIMIZATION_LEVEL = 0; 205 | GCC_PREPROCESSOR_DEFINITIONS = ( 206 | "DEBUG=1", 207 | "$(inherited)", 208 | ); 209 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 210 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 211 | GCC_WARN_UNDECLARED_SELECTOR = YES; 212 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 213 | GCC_WARN_UNUSED_FUNCTION = YES; 214 | GCC_WARN_UNUSED_VARIABLE = YES; 215 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 216 | MTL_ENABLE_DEBUG_INFO = YES; 217 | ONLY_ACTIVE_ARCH = YES; 218 | SDKROOT = iphoneos; 219 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 220 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 221 | TARGETED_DEVICE_FAMILY = "1,2"; 222 | }; 223 | name = Debug; 224 | }; 225 | 39974D431D8BF66500110310 /* Release */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ALWAYS_SEARCH_USER_PATHS = NO; 229 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 230 | CLANG_ANALYZER_NONNULL = YES; 231 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 232 | CLANG_CXX_LIBRARY = "libc++"; 233 | CLANG_ENABLE_MODULES = YES; 234 | CLANG_ENABLE_OBJC_ARC = YES; 235 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 236 | CLANG_WARN_BOOL_CONVERSION = YES; 237 | CLANG_WARN_COMMA = YES; 238 | CLANG_WARN_CONSTANT_CONVERSION = YES; 239 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 240 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 241 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 242 | CLANG_WARN_EMPTY_BODY = YES; 243 | CLANG_WARN_ENUM_CONVERSION = YES; 244 | CLANG_WARN_INFINITE_RECURSION = YES; 245 | CLANG_WARN_INT_CONVERSION = YES; 246 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 247 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 248 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 250 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 251 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 252 | CLANG_WARN_STRICT_PROTOTYPES = YES; 253 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 254 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 255 | CLANG_WARN_UNREACHABLE_CODE = YES; 256 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 257 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 258 | COPY_PHASE_STRIP = NO; 259 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 260 | ENABLE_NS_ASSERTIONS = NO; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | GCC_C_LANGUAGE_STANDARD = gnu99; 263 | GCC_NO_COMMON_BLOCKS = YES; 264 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 266 | GCC_WARN_UNDECLARED_SELECTOR = YES; 267 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 268 | GCC_WARN_UNUSED_FUNCTION = YES; 269 | GCC_WARN_UNUSED_VARIABLE = YES; 270 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 271 | MTL_ENABLE_DEBUG_INFO = NO; 272 | SDKROOT = iphoneos; 273 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 274 | TARGETED_DEVICE_FAMILY = "1,2"; 275 | VALIDATE_PRODUCT = YES; 276 | }; 277 | name = Release; 278 | }; 279 | 39974D451D8BF66500110310 /* Debug */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 283 | CLANG_ENABLE_MODULES = YES; 284 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 285 | DEVELOPMENT_TEAM = S9QFG2VH2E; 286 | INFOPLIST_FILE = LNChevronViewExample/Info.plist; 287 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 288 | PRODUCT_BUNDLE_IDENTIFIER = com.LeoNatan.LNChevronViewExample; 289 | PRODUCT_NAME = "$(TARGET_NAME)"; 290 | SWIFT_OBJC_BRIDGING_HEADER = "LNChevronViewExample/LNChevronViewExample-Bridging-Header.h"; 291 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 292 | SWIFT_VERSION = 5.0; 293 | }; 294 | name = Debug; 295 | }; 296 | 39974D461D8BF66500110310 /* Release */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 300 | CLANG_ENABLE_MODULES = YES; 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | DEVELOPMENT_TEAM = S9QFG2VH2E; 303 | INFOPLIST_FILE = LNChevronViewExample/Info.plist; 304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 305 | PRODUCT_BUNDLE_IDENTIFIER = com.LeoNatan.LNChevronViewExample; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | SWIFT_OBJC_BRIDGING_HEADER = "LNChevronViewExample/LNChevronViewExample-Bridging-Header.h"; 308 | SWIFT_VERSION = 5.0; 309 | }; 310 | name = Release; 311 | }; 312 | /* End XCBuildConfiguration section */ 313 | 314 | /* Begin XCConfigurationList section */ 315 | 39974D2D1D8BF66500110310 /* Build configuration list for PBXProject "LNChevronViewExample" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | 39974D421D8BF66500110310 /* Debug */, 319 | 39974D431D8BF66500110310 /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | defaultConfigurationName = Release; 323 | }; 324 | 39974D441D8BF66500110310 /* Build configuration list for PBXNativeTarget "LNChevronViewExample" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 39974D451D8BF66500110310 /* Debug */, 328 | 39974D461D8BF66500110310 /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | /* End XCConfigurationList section */ 334 | }; 335 | rootObject = 39974D2A1D8BF66500110310 /* Project object */; 336 | } 337 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LNChevronViewExample 4 | // 5 | // Created by Leo Natan on 16/9/16. 6 | // Copyright © 2016 Leo Natan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | Main 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/LNChevronViewExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "LNChevronView.h" 6 | -------------------------------------------------------------------------------- /LNChevronViewExample/LNChevronViewExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // LNChevronViewExample 4 | // 5 | // Created by Leo Natan on 16/9/16. 6 | // Copyright © 2016 Leo Natan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | @IBOutlet weak var chevronView: LNChevronView! 13 | @IBOutlet var chevronViews: [LNChevronView]! 14 | 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // Do any additional setup after loading the view, typically from a nib. 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | @IBAction func _toggleButtonTapped(_ sender: UIButton) { 27 | var nextState = LNChevronViewState(rawValue: chevronView.state.rawValue + 1)! 28 | if nextState.rawValue > 1 { 29 | nextState = .up 30 | } 31 | chevronViews.forEach { $0.setState(nextState, animated: true) } 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LNChevronView 2 | 3 | 4 | 5 | Customizable chevron view reimplementation of Apple's, as seen in Springboard / Apple Music. Can be customized directly from Xcode. 6 | 7 | ## Adding to Your Project 8 | 9 | ### Carthage 10 | 11 | Add the following to your Cartfile: 12 | 13 | ```github "LeoNatan/LNChevronView"``` 14 | 15 | ### Manual 16 | 17 | Drag `LNChevronView.h` and `LNChevronView.m` to your project. 18 | 19 | ## Using 20 | 21 | Import the header file: 22 | 23 | ```#import "LNChevronView.h"``` 24 | 25 | For Swift projects, add the above import statement to your bridging header file. 26 | 27 | You can control all properties of the chevron view from Interface Builder: 28 | 29 | 30 | 31 | Chevron state is controlled using the `state` property. To set the state with animation, use `setState:animated:`/`setState(_,animated:)`. 32 | Other properties of interest include `color`, `width` and `animationDuration`. 33 | -------------------------------------------------------------------------------- /Supplements/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeoNatan/LNChevronView/2e469b96e9d8ea3bbf0ec83b244d72f11526a2c2/Supplements/Screenshot.png -------------------------------------------------------------------------------- /Supplements/chevron.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeoNatan/LNChevronView/2e469b96e9d8ea3bbf0ec83b244d72f11526a2c2/Supplements/chevron.gif --------------------------------------------------------------------------------