Instantly share code, notes, and snippets.
Last active
August 23, 2016 07:35
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save duraiganesh0/a61a2487cd687f4aa2668f8f19a080da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DCPathButton.h | |
// DCPathButton | |
// | |
// Created by tang dixi on 30/7/14. | |
// Copyright (c) 2014 Tangdxi. All rights reserved. | |
// | |
#import "DCPathItemButton.h" | |
@import UIKit; | |
@import QuartzCore; | |
@import AudioToolbox; | |
@class DCPathButton; | |
typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { | |
kDCPathButtonBloomDirectionTop = 1, | |
kDCPathButtonBloomDirectionTopLeft = 2, | |
kDCPathButtonBloomDirectionLeft = 3, | |
kDCPathButtonBloomDirectionBottomLeft = 4, | |
kDCPathButtonBloomDirectionBottom = 5, | |
kDCPathButtonBloomDirectionBottomRight = 6, | |
kDCPathButtonBloomDirectionRight = 7, | |
kDCPathButtonBloomDirectionTopRight = 8, | |
}; | |
@protocol DCPathButtonDelegate <NSObject> | |
- (void)pathButton:(DCPathButton *)dcPathButton clickItemButtonAtIndex:(NSUInteger)itemButtonIndex; | |
@optional | |
- (void)willPresentDCPathButtonItems:(DCPathButton *)dcPathButton; | |
- (void)didPresentDCPathButtonItems:(DCPathButton *)dcPathButton; | |
- (void)willDismissDCPathButtonItems:(DCPathButton *)dcPathButton; | |
- (void)didDismissDCPathButtonItems:(DCPathButton *)dcPathButton; | |
@end | |
@interface DCPathButton : UIView <UIGestureRecognizerDelegate> | |
@property (weak, nonatomic) id<DCPathButtonDelegate> delegate; | |
@property (assign, nonatomic) CGFloat bloomRadius; | |
@property (assign, nonatomic) CGFloat bloomAngel; | |
@property (assign, nonatomic) CGPoint dcButtonCenter; | |
@property (assign, nonatomic) BOOL allowSounds; | |
@property (copy, nonatomic) NSString *bloomSoundPath; | |
@property (copy, nonatomic) NSString *foldSoundPath; | |
@property (copy, nonatomic) NSString *itemSoundPath; | |
@property (assign, nonatomic) BOOL allowCenterButtonRotation; | |
@property (strong, nonatomic) UIColor *bottomViewColor; | |
@property (assign, nonatomic) kDCPathButtonBloomDirection bloomDirection; | |
- (instancetype)initWithCenterImage:(UIImage *)centerImage | |
highlightedImage:(UIImage *)centerHighlightedImage; | |
- (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame | |
centerImage:(UIImage *)centerImage | |
highlightedImage:(UIImage *)centerHighlightedImage; | |
- (void)addPathItems:(NSArray *)pathItemButtons; | |
- (void)centerButtonTapped; | |
@end | |
// here i call the method | |
func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool { | |
DCPathButton().centerButtonTapped() | |
return true | |
} | |
// this was yesterday's code | |
func configureDCPathButton(marker: GMSMarker) { | |
var coordinate = marker.position | |
var point = viewGMap.projection.pointForCoordinate(coordinate) | |
var dcPathButton:DCPathButton! | |
dcPathButton = DCPathButton(centerImage: self.drawImage(self.userImage!), highlightedImage: self.drawImage(self.userImage!)) | |
dcPathButton.delegate = self | |
dcPathButton.dcButtonCenter = point //CGPointMake(self.viewGMap.bounds.width/2, self.viewGMap.bounds.height - 25.5) | |
dcPathButton.allowSounds = true | |
dcPathButton.allowCenterButtonRotation = true | |
dcPathButton.bloomRadius = 105 | |
let itemButton_1 = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-music"), highlightedImage: UIImage(named: "chooser-moment-icon-music-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) | |
let itemButton_2 = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-place"), highlightedImage: UIImage(named: "chooser-moment-icon-place-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) | |
let itemButton_3 = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-camera"), highlightedImage: UIImage(named: "chooser-moment-icon-camera-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) | |
let itemButton_4 = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-thought"), highlightedImage: UIImage(named: "chooser-moment-icon-thought-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) | |
let itemButton_5 = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-sleep"), highlightedImage: UIImage(named: "chooser-moment-icon-sleep-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) | |
dcPathButton.addPathItems([itemButton_1, itemButton_2, itemButton_3, itemButton_4, itemButton_5]) | |
self.view.addSubview(dcPathButton) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment