Skip to content
Permalink
Browse files

add supporting for custom destination coordinate

  • Loading branch information...
noark9 committed Jan 10, 2017
1 parent 5144a20 commit e6dbe1bdd3cec9a9391c3da0ff84161003f5e7d3
Showing with 61 additions and 34 deletions.
  1. +7 −0 FancyTabBar.xcodeproj/project.pbxproj
  2. +2 −0 FancyTabBar/FancyTabBar.h
  3. +44 −33 FancyTabBar/FancyTabBar.m
  4. +8 −1 FancyTabBar/ViewController.m
@@ -236,6 +236,9 @@
attributes = {
LastUpgradeCheck = 0510;
TargetAttributes = {
AB8F048819B6FEAB004CFDED = {
DevelopmentTeam = 7H6KWF2CU7;
};
AB8F04A919B6FEAC004CFDED = {
TestTargetID = AB8F048819B6FEAB004CFDED;
};
@@ -417,6 +420,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = 7H6KWF2CU7;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "FancyTabBar/FancyTabBar-Prefix.pch";
INFOPLIST_FILE = "FancyTabBar/FancyTabBar-Info.plist";
@@ -430,6 +434,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
DEVELOPMENT_TEAM = 7H6KWF2CU7;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "FancyTabBar/FancyTabBar-Prefix.pch";
INFOPLIST_FILE = "FancyTabBar/FancyTabBar-Info.plist";
@@ -497,6 +502,7 @@
AB8F04BD19B6FEAC004CFDED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AB8F04BE19B6FEAC004CFDED /* Build configuration list for PBXNativeTarget "FancyTabBarTests" */ = {
isa = XCConfigurationList;
@@ -505,6 +511,7 @@
AB8F04C019B6FEAC004CFDED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -24,4 +24,6 @@ typedef enum {

- (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*) choices withMainButtonImage:(UIImage*)mainButtonImage;
- (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*) choices withMainButtonImage:(UIImage*)mainButtonImage andMainButtonCustomOrigin:(CGPoint)customOrigin;
- (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*) choices withMainButtonImage:(UIImage*)mainButtonImage andMainButtonCustomOrigin:(CGPoint)customOrigin choicesCoordinates:(NSArray*)choicesCoordinates;

@end
@@ -33,7 +33,8 @@ @interface FancyTabBar(){
@property(nonatomic,strong) UIView *backgroundView;
@property(nonatomic,strong) UIDynamicAnimator *dynamicsAnimator;
@property(nonatomic,strong) UIDynamicBehavior *dynamicBehaviour;
@property (assign, nonatomic) CGPoint mainBtnCustomOrigin;
@property(assign, nonatomic) CGPoint mainBtnCustomOrigin;
@property(nonatomic, copy) NSArray *choiceCoordinates;

@property(nonatomic,weak) UIViewController *parentViewController;

@@ -79,6 +80,10 @@ - (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*
_mainBtnCustomOrigin=customOrigin;
[self setUpChoices:parentViewController choices:choices withMainButtonImage:mainButtonImage];
}
- (void) setUpChoices:(UIViewController *)parentViewController choices:(NSArray *)choices withMainButtonImage:(UIImage *)mainButtonImage andMainButtonCustomOrigin:(CGPoint)customOrigin choicesCoordinates:(NSArray *)choicesCoordinates {
self.choiceCoordinates = choicesCoordinates;
[self setUpChoices:parentViewController choices:choices withMainButtonImage:mainButtonImage andMainButtonCustomOrigin:customOrigin];
}
- (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*) choices withMainButtonImage:(UIImage*)mainButtonImage{
_parentViewController = parentViewController;
_choices = choices;
@@ -158,43 +163,49 @@ - (void) calculateExpandedCoordinates{
[self addSubview:button];
}

float plane = (parentWidth)-2*PADDING;
float radius = plane/3;
float xCentre = _mainButton.center.x;
float yCentre = _mainButton.center.y;


float x;
float y;

float degrees = 180/(_choices.count-1);

for (int i=0; i < _choices.count; i++) {
int tag = (i+1)*subviewTagConstant;
Coordinate *coordinate = [[Coordinate alloc] init];
float radian = (degrees*(i)*M_PI)/180;
if (_currentDirectionToPopOptions==FancyTabBarItemsPop_Down) {
//Pop Option Buttons Down
radian = (degrees*(i)*M_PI)/-180;
}
float cosineRadian = cosf(radian);
float sineRadian = sinf(radian);

float radiusLengthX = (radius * cosineRadian);
float radiusLengthY = (radius * sineRadian);
if (!self.choiceCoordinates && self.choiceCoordinates.count == _choices.count) {
float plane = (parentWidth)-2*PADDING;
float radius = plane/3;
float xCentre = _mainButton.center.x;
float yCentre = _mainButton.center.y;

x = xCentre + radiusLengthX;
y = yCentre - radiusLengthY;

coordinate.x = [NSNumber numberWithInt:x];
coordinate.y = [NSNumber numberWithInt:y];
float x;
float y;

coordinate.x = [NSNumber numberWithInt:x];
float degrees = 180/(_choices.count-1);

coordinate.y = [NSNumber numberWithFloat:y];
[_destinationCoordinateDictionary setObject:coordinate forKey:[NSNumber numberWithInt:tag]];
for (int i=0; i < _choices.count; i++) {
int tag = (i+1)*subviewTagConstant;
Coordinate *coordinate = [[Coordinate alloc] init];
float radian = (degrees*(i)*M_PI)/180;
if (_currentDirectionToPopOptions==FancyTabBarItemsPop_Down) {
//Pop Option Buttons Down
radian = (degrees*(i)*M_PI)/-180;
}
float cosineRadian = cosf(radian);
float sineRadian = sinf(radian);

float radiusLengthX = (radius * cosineRadian);
float radiusLengthY = (radius * sineRadian);

x = xCentre + radiusLengthX;
y = yCentre - radiusLengthY;

coordinate.x = [NSNumber numberWithInt:x];
coordinate.y = [NSNumber numberWithInt:y];

coordinate.x = [NSNumber numberWithInt:x];

coordinate.y = [NSNumber numberWithFloat:y];
[_destinationCoordinateDictionary setObject:coordinate forKey:[NSNumber numberWithInt:tag]];
}
} else {
for (int i = 0; i < self.choiceCoordinates.count; i++) {
int tag = (i + 1) * subviewTagConstant;
[_destinationCoordinateDictionary setObject:self.choiceCoordinates[i] forKey:@(tag)];
}
}

}

#pragma mark - animation
@@ -10,6 +10,7 @@
#import "UIView+Screenshot.h"
#import "UIImage+ImageEffects.h"
#import "FancyTabBar.h"
#import "Coordinate.h"

@interface ViewController ()<FancyTabBarDelegate>

@@ -25,7 +26,13 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_fancyTabBar = [[FancyTabBar alloc]initWithFrame:self.view.bounds];
[_fancyTabBar setUpChoices:self choices:@[@"gallery",@"dropbox",@"camera",@"draw"] withMainButtonImage:[UIImage imageNamed:@"main_button"]];
Coordinate *c1 = [[Coordinate alloc] init];
c1.y = @([UIScreen mainScreen].bounds.size.height - 88.0f - 109.0f);
c1.x = @75.0f;
Coordinate *c2 = [[Coordinate alloc] init];
c2.y = c1.y;
c2.x = @(88.0f + 50.0f + c1.x.doubleValue);
[_fancyTabBar setUpChoices:self choices:@[@"camera",@"draw"] withMainButtonImage:[UIImage imageNamed:@"main_button"] andMainButtonCustomOrigin:CGPointMake(100.0f, 100.0f) choicesCoordinates:@[c1, c2]];
// //Set Pop Items Direction
// _fancyTabBar.currentDirectionToPopOptions=FancyTabBarItemsPop_Down;
// //Custom Placement

0 comments on commit e6dbe1b

Please sign in to comment.
You can’t perform that action at this time.