diff --git a/DCPathButton/Classes/DCPathButton.h b/DCPathButton/Classes/DCPathButton.h index 837b6bf..0a442b9 100644 --- a/DCPathButton/Classes/DCPathButton.h +++ b/DCPathButton/Classes/DCPathButton.h @@ -14,63 +14,182 @@ @class DCPathButton; +/*! + * The direction of a `DCPathButton` object's bloom animation. + */ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { - + /*! + * Bloom animation gose to the top of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionTop = 1, + /*! + * Bloom animation gose to top left of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionTopLeft = 2, + /*! + * Bloom animation gose to the left of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionLeft = 3, + /*! + * Bloom animation gose to bottom left of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionBottomLeft = 4, + /*! + * Bloom animation gose to the bottom of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionBottom = 5, + /*! + * Bloom animation gose to bottom right of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionBottomRight = 6, + /*! + * Bloom animation gose to the right of the `DCPathButton` object. + */ kDCPathButtonBloomDirectionRight = 7, + /*! + * Bloom animation gose around the `DCPathButton` object. + */ kDCPathButtonBloomDirectionTopRight = 8, - }; +/*! + * `DCPathButtonDelegate` protocol defines methods that inform the delegate object the events of item button's selection, presentation and dismissal. + */ @protocol DCPathButtonDelegate +/*! + * Tells the delegate that the item button at an index is clicked. + * + * @param dcPathButton A `DCPathButton` object informing the delegate about the button click. + * @param itemButtonIndex The index of the item button being clicked. + */ - (void)pathButton:(DCPathButton *)dcPathButton clickItemButtonAtIndex:(NSUInteger)itemButtonIndex; @optional +/*! + * Tells the delegate that the `DCPathButton` object will present its items. + * + * @param dcPathButton A `DCPathButton` object that is about to present its items. + */ - (void)willPresentDCPathButtonItems:(DCPathButton *)dcPathButton; +/*! + * Tells the delegate that the `DCPathButton` object has already presented its items. + * + * @param dcPathButton A `DCPathButton` object that has presented its items. + */ - (void)didPresentDCPathButtonItems:(DCPathButton *)dcPathButton; +/*! + * Tells the delegate that the `DCPathButton` object will dismiss its items. + * + * @param dcPathButton A `DCPathButton` object that is about to dismiss its items + */ - (void)willDismissDCPathButtonItems:(DCPathButton *)dcPathButton; +/*! + * Tells the delegate that the `DCPathButton` object has already dismissed its items. + * + * @param dcPathButton A `DCPathButton` object that has dismissed its items. + */ - (void)didDismissDCPathButtonItems:(DCPathButton *)dcPathButton; @end @interface DCPathButton : UIView +/*! + * The object that acts as the delegate of the `DCPathButton` object. + */ @property (weak, nonatomic) id delegate; +/*! + * `DCPathButton` object's bloom animation's duration. + */ @property (assign, nonatomic) NSTimeInterval basicDuration; +/*! + * `YES` if allows `DCPathButton` object's sub items to rotate. Otherwise `NO`. + */ @property (assign, nonatomic) BOOL allowSubItemRotation; +/*! + * `DCPathButton` object's bloom radius. The default value is 105.0f. + */ @property (assign, nonatomic) CGFloat bloomRadius; + +/*! + * `DCPathButton` object's bloom angle. + */ @property (assign, nonatomic) CGFloat bloomAngel; + +/*! + * The center of a `DCPathButton` object's position. The default value positions the `DCPathButton` object in bottom center. + */ @property (assign, nonatomic) CGPoint dcButtonCenter; +/*! + * If set to `YES` a sound will be played when the `DCPathButton` object is being interacted. The default value is `YES`. + */ @property (assign, nonatomic) BOOL allowSounds; +/*! + * The path to the `DCPathButton` object's bloom effect sound file. + */ @property (copy, nonatomic) NSString *bloomSoundPath; + +/*! + * The path to the `DCPathButton` object's fold effect sound file. + */ @property (copy, nonatomic) NSString *foldSoundPath; + +/*! + * The path to the `DCPathButton` object's item action sound file. + */ @property (copy, nonatomic) NSString *itemSoundPath; +/*! + * `YES` if allows the `DCPathButton` object's center button to rotate. Otherwise `NO`. + */ @property (assign, nonatomic) BOOL allowCenterButtonRotation; +/*! + * Color of the backdrop view when `DCPathButton` object's sub items are shown. + */ @property (strong, nonatomic) UIColor *bottomViewColor; +/*! + * Direction of `DCPathButton` object's bloom animation. + */ @property (assign, nonatomic) kDCPathButtonBloomDirection bloomDirection; +/*! + * Creates a `DCPathButton` object with a given normal image and highlited images for center button. + * + * @param centerImage The normal image for `DCPathButton` object's center button. + * @param centerHighlightedImage The highlighted image for `DCPathButton` object's center button. + * + * @return A `DCPathButton` object. + */ - (instancetype)initWithCenterImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage; +/*! + * Creates a `DCPathButton` object with a given frame, normal and highlighted images for its center button. + * + * @param centerButtonFrame The frame of `DCPathButton` object. + * @param centerImage The normal image for `DCPathButton` object's center button. + * @param centerHighlightedImage The highlighted image for `DCPathButton` object's center button. + * + * @return A `DCPathButton` object. + */ - (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame centerImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage; +/*! + * Adds item buttons to an existing `DCPathButton` object. + * + * @param pathItemButtons The item buttons to be added. + */ - (void)addPathItems:(NSArray *)pathItemButtons; @end diff --git a/DCPathButton/Classes/DCPathItemButton.h b/DCPathButton/Classes/DCPathItemButton.h index cf19942..2c405c4 100644 --- a/DCPathButton/Classes/DCPathItemButton.h +++ b/DCPathButton/Classes/DCPathItemButton.h @@ -10,17 +10,42 @@ @class DCPathItemButton; +/*! + * `DCPathItemButtonDelegate` protocol defines method that informs the delegate object the event of item button's selection. + */ @protocol DCPathItemButtonDelegate +/*! + * Tells the delegate that the `DCPathItemButton` has been selected. + * + * @param itemButton A `DCPathItemButton` that has been selected. + */ - (void)itemButtonTapped:(DCPathItemButton *)itemButton; @end @interface DCPathItemButton : UIButton +/*! + * The location of the `DCPathItemButton` object in a `DCPathButton` object. + */ @property (assign, nonatomic) NSUInteger index; + +/*! + * The object that acts as the delegate of the `DCPathItemButton` object. + */ @property (weak, nonatomic) id delegate; +/*! + * Creates a `DCPathItemButton` with normal and highlighted foreground and background images of the button. + * + * @param image The normal foreground image. + * @param highlightedImage The highlighted foreground image. + * @param backgroundImage The normal background image. + * @param backgroundHighlightedImage The highlighted background image. + * + * @return A `DCPathItemButton` object. + */ - (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage backgroundImage:(UIImage *)backgroundImage diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 7a90445..5b975e3 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ 0D964741D00C43C7F00D3507 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DD23BAC82943B6BA709779 /* libPods.a */; }; - 43F4EFF81BE0B65B00FC8D9A /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 43F4EFF71BE0B65B00FC8D9A /* Default-568h@2x.png */; settings = {ASSET_TAGS = (); }; }; - 43F4EFFE1BE70BAF00FC8D9A /* BarButtonItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 43F4EFFD1BE70BAF00FC8D9A /* BarButtonItemViewController.m */; settings = {ASSET_TAGS = (); }; }; + 43F4EFF81BE0B65B00FC8D9A /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 43F4EFF71BE0B65B00FC8D9A /* Default-568h@2x.png */; }; + 43F4EFFE1BE70BAF00FC8D9A /* BarButtonItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 43F4EFFD1BE70BAF00FC8D9A /* BarButtonItemViewController.m */; }; 810D19761B41293E0032125D /* TabBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810D19751B41293E0032125D /* TabBarViewController.m */; }; 810D19791B412DCF0032125D /* UIScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810D19781B412DCF0032125D /* UIScrollViewController.m */; }; 81696CC91999D748001B9B4B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81696CC81999D748001B9B4B /* Foundation.framework */; }; @@ -232,7 +232,7 @@ 81696CBD1999D748001B9B4B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0730; ORGANIZATIONNAME = Tangdxi; TargetAttributes = { 81696CE51999D748001B9B4B = { @@ -392,6 +392,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -452,6 +453,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Example/Example-Prefix.pch"; INFOPLIST_FILE = "Example/Example-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "DC.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -465,6 +467,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Example/Example-Prefix.pch"; INFOPLIST_FILE = "Example/Example-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "DC.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -486,6 +489,7 @@ "$(inherited)", ); INFOPLIST_FILE = "ExampleTests/ExampleTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "DC.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; @@ -504,6 +508,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Example/Example-Prefix.pch"; INFOPLIST_FILE = "ExampleTests/ExampleTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "DC.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; diff --git a/Example/Example/BarButtonItemViewController.m b/Example/Example/BarButtonItemViewController.m index b2f1ac1..070e451 100644 --- a/Example/Example/BarButtonItemViewController.m +++ b/Example/Example/BarButtonItemViewController.m @@ -65,4 +65,9 @@ - (void)viewDidLoad { } +#pragma mark - DCPathButtonDelegate +- (void)pathButton:(DCPathButton *)dcPathButton clickItemButtonAtIndex:(NSUInteger)itemButtonIndex { + NSLog(@"You tap %@ at index : %tu", dcPathButton, itemButtonIndex); +} + @end diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard index d98ece8..8ca3f01 100644 --- a/Example/Example/Base.lproj/Main.storyboard +++ b/Example/Example/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -251,7 +251,7 @@ - + diff --git a/Example/Example/Example-Info.plist b/Example/Example/Example-Info.plist index a848a38..01ee4b6 100644 --- a/Example/Example/Example-Info.plist +++ b/Example/Example/Example-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - DC.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example/Example/TabBarViewController.m b/Example/Example/TabBarViewController.m index e8d1f2c..f732f18 100644 --- a/Example/Example/TabBarViewController.m +++ b/Example/Example/TabBarViewController.m @@ -102,7 +102,7 @@ - (void)willPresentDCPathButtonItems:(DCPathButton *)dcPathButton { } - (void)pathButton:(DCPathButton *)dcPathButton clickItemButtonAtIndex:(NSUInteger)itemButtonIndex { - NSLog(@"You tap %@ at index : %lu", dcPathButton, (unsigned long)itemButtonIndex); + NSLog(@"You tap %@ at index : %tu", dcPathButton, itemButtonIndex); } - (void)didPresentDCPathButtonItems:(DCPathButton *)dcPathButton { diff --git a/Example/ExampleTests/ExampleTests-Info.plist b/Example/ExampleTests/ExampleTests-Info.plist index 37bd968..169b6f7 100644 --- a/Example/ExampleTests/ExampleTests-Info.plist +++ b/Example/ExampleTests/ExampleTests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - DC.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType