@@ -33,7 +33,8 @@ @interface FancyTabBar(){
33
33
@property (nonatomic ,strong ) UIView *backgroundView;
34
34
@property (nonatomic ,strong ) UIDynamicAnimator *dynamicsAnimator;
35
35
@property (nonatomic ,strong ) UIDynamicBehavior *dynamicBehaviour;
36
- @property (assign , nonatomic ) CGPoint mainBtnCustomOrigin;
36
+ @property (assign , nonatomic ) CGPoint mainBtnCustomOrigin;
37
+ @property (nonatomic , copy ) NSArray *choiceCoordinates;
37
38
38
39
@property (nonatomic ,weak ) UIViewController *parentViewController;
39
40
@@ -79,6 +80,10 @@ - (void) setUpChoices:(UIViewController*) parentViewController choices:(NSArray*
79
80
_mainBtnCustomOrigin=customOrigin;
80
81
[self setUpChoices: parentViewController choices: choices withMainButtonImage: mainButtonImage];
81
82
}
83
+ - (void ) setUpChoices : (UIViewController *)parentViewController choices : (NSArray *)choices withMainButtonImage : (UIImage *)mainButtonImage andMainButtonCustomOrigin : (CGPoint)customOrigin choicesCoordinates : (NSArray *)choicesCoordinates {
84
+ self.choiceCoordinates = choicesCoordinates;
85
+ [self setUpChoices: parentViewController choices: choices withMainButtonImage: mainButtonImage andMainButtonCustomOrigin: customOrigin];
86
+ }
82
87
- (void ) setUpChoices : (UIViewController*) parentViewController choices : (NSArray *) choices withMainButtonImage : (UIImage*)mainButtonImage {
83
88
_parentViewController = parentViewController;
84
89
_choices = choices;
@@ -158,43 +163,49 @@ - (void) calculateExpandedCoordinates{
158
163
[self addSubview: button];
159
164
}
160
165
161
- float plane = (parentWidth)-2 *PADDING;
162
- float radius = plane/3 ;
163
- float xCentre = _mainButton.center .x ;
164
- float yCentre = _mainButton.center .y ;
165
-
166
-
167
- float x;
168
- float y;
169
-
170
- float degrees = 180 /(_choices.count -1 );
171
-
172
- for (int i=0 ; i < _choices.count ; i++) {
173
- int tag = (i+1 )*subviewTagConstant;
174
- Coordinate *coordinate = [[Coordinate alloc ] init ];
175
- float radian = (degrees*(i)*M_PI)/180 ;
176
- if (_currentDirectionToPopOptions==FancyTabBarItemsPop_Down) {
177
- // Pop Option Buttons Down
178
- radian = (degrees*(i)*M_PI)/-180 ;
179
- }
180
- float cosineRadian = cosf (radian);
181
- float sineRadian = sinf (radian);
182
-
183
- float radiusLengthX = (radius * cosineRadian);
184
- float radiusLengthY = (radius * sineRadian);
166
+ if (!self.choiceCoordinates && self.choiceCoordinates .count == _choices.count ) {
167
+ float plane = (parentWidth)-2 *PADDING;
168
+ float radius = plane/3 ;
169
+ float xCentre = _mainButton.center .x ;
170
+ float yCentre = _mainButton.center .y ;
185
171
186
- x = xCentre + radiusLengthX;
187
- y = yCentre - radiusLengthY;
188
172
189
- coordinate. x = [ NSNumber numberWithInt: x] ;
190
- coordinate. y = [ NSNumber numberWithInt: y] ;
173
+ float x ;
174
+ float y ;
191
175
192
- coordinate. x = [ NSNumber numberWithInt: x] ;
176
+ float degrees = 180 /(_choices. count - 1 ) ;
193
177
194
- coordinate.y = [NSNumber numberWithFloat: y];
195
- [_destinationCoordinateDictionary setObject: coordinate forKey: [NSNumber numberWithInt: tag]];
178
+ for (int i=0 ; i < _choices.count ; i++) {
179
+ int tag = (i+1 )*subviewTagConstant;
180
+ Coordinate *coordinate = [[Coordinate alloc ] init ];
181
+ float radian = (degrees*(i)*M_PI)/180 ;
182
+ if (_currentDirectionToPopOptions==FancyTabBarItemsPop_Down) {
183
+ // Pop Option Buttons Down
184
+ radian = (degrees*(i)*M_PI)/-180 ;
185
+ }
186
+ float cosineRadian = cosf (radian);
187
+ float sineRadian = sinf (radian);
188
+
189
+ float radiusLengthX = (radius * cosineRadian);
190
+ float radiusLengthY = (radius * sineRadian);
191
+
192
+ x = xCentre + radiusLengthX;
193
+ y = yCentre - radiusLengthY;
194
+
195
+ coordinate.x = [NSNumber numberWithInt: x];
196
+ coordinate.y = [NSNumber numberWithInt: y];
197
+
198
+ coordinate.x = [NSNumber numberWithInt: x];
199
+
200
+ coordinate.y = [NSNumber numberWithFloat: y];
201
+ [_destinationCoordinateDictionary setObject: coordinate forKey: [NSNumber numberWithInt: tag]];
202
+ }
203
+ } else {
204
+ for (int i = 0 ; i < self.choiceCoordinates .count ; i++) {
205
+ int tag = (i + 1 ) * subviewTagConstant;
206
+ [_destinationCoordinateDictionary setObject: self .choiceCoordinates[i] forKey: @(tag)];
207
+ }
196
208
}
197
-
198
209
}
199
210
200
211
#pragma mark - animation
0 commit comments