-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathSWBTabBarView.m
637 lines (521 loc) · 21.4 KB
/
SWBTabBarView.m
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
//
// SWBTabBarView.m
// SWBuaWeb
//
// Created by clowwindy on 11-6-10.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import "SWBTabBarView.h"
//#import "SWBuaWebAppDelegate.h"
#define kTabBarMinTabWidth 120
#define kTabBarMaxTabWidth 280
#define kTabBarTabInset 20
#define kTabBarNewTabButtonWidth 40
#define kTabBarTopColor 0.85
#define kTabBarBottomColor 0.85
#define kTabBarOverflowTabAlpha 0.3
#define kTabBarDraggingTabAlpha 0.5
//#define kTabBarLongPressDraggingOffsetThreshold 10
@implementation SWBTabBarView
@synthesize delegate, tabs, currentTab, firstLeftTab;
-(UIView *)aNewTabButton {
return newTabButton;
}
- (void)loadDefaults {
self.clipsToBounds = YES;
currentMaxTag = 0;
tabs = [[NSMutableArray alloc] init];
tabViews = [[NSMutableArray alloc] init];
newTabButton = [[SWBNewTabButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[newTabButton addTarget:self action:@selector(newTabButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:newTabButton];
[newTabButton setAccessibilityLabel:NSLocalizedString(@"Open New Tab", @"")];
// init gestures
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[self addGestureRecognizer:panGestureRecognizer];
// [self addGestureRecognizer:longPressGestureRecognizer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(settingsChanged) name:NSUserDefaultsDidChangeNotification object:nil];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self loadDefaults];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Initialization code
[self loadDefaults];
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
// CGContextClipToRect(context, rect);
CGFloat width = self.bounds.size.width;
CGGradientRef myGradient;
CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = {
kTabBarTopColor, kTabBarTopColor, kTabBarTopColor, 1.0,
kTabBarBottomColor, kTabBarBottomColor, kTabBarBottomColor, 1.0 };
myGradient = CGGradientCreateWithColorComponents (myColorspace, components,
locations, num_locations);
CGPoint myStartPoint, myEndPoint;
myStartPoint.x = 0;
myStartPoint.y = 0;
myEndPoint.x = 0;
myEndPoint.y = kTabBarHeight;
CGContextDrawLinearGradient(context, myGradient, myStartPoint,
myEndPoint,
kCGGradientDrawsAfterEndLocation);
CGContextSetLineWidth(context, 1);
CGContextMoveToPoint(context, 0, 0);
CGContextSetRGBStrokeColor(context, 0.2, 0.2, 0.2, 1);
CGContextAddLineToPoint(context, width, 0);
CGContextDrawPath(context, kCGPathStroke);
// CGContextMoveToPoint(context, 0, 1);
// CGContextSetRGBStrokeColor(context, 1, 1, 1, 1);
// CGContextAddLineToPoint(context, width, 1);
// CGContextDrawPath(context, kCGPathStroke);
CGGradientRelease(myGradient);
CGColorSpaceRelease(myColorspace);
}
#pragma mark:tab layout
-(SWBTabView *)tabViewByTag:(NSInteger)tag {
for (SWBTabView *tabView in tabViews) {
if (tabView.tag == tag) {
return tabView;
}
}
return nil;
}
-(SWBTab *)tabByTag:(NSInteger)tag {
for (SWBTab *tab in tabs) {
if (tab.tag == tag) {
return tab;
}
}
return nil;
}
-(void)moveNewTabButtonToTop {
if ([self.subviews indexOfObject: newTabButton] != [self.subviews count] - 1) {
[newTabButton removeFromSuperview];
[self addSubview:newTabButton];
}
}
// 调整所有标签页的上下顺序
-(void)reorderTabViews {
SWBTabView *currentTabView = nil;
SWBTabView *lastTabView = nil;
NSArray *s_subviews = self.subviews;
SWBTabView *currentDraggingTabView = nil;
BOOL startToSwap = NO;
if (currentDraggingTab != nil) {
currentDraggingTabView = [self tabViewByTag:currentDraggingTab.tag];
[newTabButton removeFromSuperview];
[self insertSubview:newTabButton belowSubview:currentDraggingTabView];
} else {
[self moveNewTabButtonToTop];
}
for (int i = [tabViews count] - 1; i >= 0; i--) {
SWBTabView *tabView = tabViews[i];
if (tabView == currentDraggingTabView || tabView.superview == nil) {
continue;
}
if (tabView.tag == currentTab.tag) {
currentTabView = tabView;
}
// 一点优化,只有当需要调换的时候才调换
// 这个算法依然存在改进的空间,比如可以通过插入的方法
if (currentDraggingTabView || startToSwap || (lastTabView && currentTabView != tabView && [s_subviews indexOfObject:lastTabView] > [s_subviews indexOfObject:tabView])) {
startToSwap = YES;
[tabView removeFromSuperview];
// [self addSubview:tabView];
[self insertSubview:tabView belowSubview:newTabButton];
}
lastTabView = tabView;
}
// 将选中的标签页移动到最上
if (currentTabView && currentDraggingTabView != currentTabView) {
[currentTabView removeFromSuperview];
[self addSubview:currentTabView];
[self insertSubview:currentTabView belowSubview:newTabButton];
}
}
-(void)initANewTabView:(SWBTabView *)tabView {
tabView.contentMode = UIViewContentModeRedraw;
[self addSubview:tabView];
[tabViews addObject:tabView];
[tabView addTarget:self action:@selector(tabClicked:) forControlEvents:UIControlEventTouchUpInside];
tabView.delegate = self;
UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
// [longPressGestureRecognizer setCancelsTouchesInView:NO];
[tabView addGestureRecognizer:longPressGestureRecognizer];
// TODO
// BOOL showEnd = [appSettingsManager showEndOfTheTitle];
BOOL showEnd = NO;
tabView.titleLabel.lineBreakMode = showEnd? NSLineBreakByTruncatingMiddle:NSLineBreakByTruncatingTail;
}
-(void)removeATabView:(SWBTabView *)tabView {
[tabView removeTarget:self action:@selector(tabClicked:) forControlEvents:UIControlEventTouchUpInside];
[tabView removeFromSuperview];
[tabViews removeObject:tabView];
// [tabView removeGestureRecognizer: [[tabView gestureRecognizers] objectAtIndex:0]];
tabView.delegate = nil;
}
// 根据横坐标计算这是第几个标签页的位置
-(NSInteger)indexForPosition:(CGFloat)position {
return position / currentTabWidth + firstLeftTab;
}
-(void)layoutTabsWithAction:(enum SWBTabBarAction)action animated:(BOOL)animated {
#ifdef DEBUG
// NSLog(@"layoutTabsWithAction");
#endif
int tabCount = [tabs count];
int visibleTabCount = 0;
CGFloat width = self.bounds.size.width;
CGFloat height = self.bounds.size.height;
CGFloat xOffset = movingOffset;
CGFloat tabWidth;
if (tabCount != 0) {
tabWidth = (width - kTabBarNewTabButtonWidth) / tabCount;
if (tabWidth < kTabBarMinTabWidth) {
visibleTabCount = (width - kTabBarNewTabButtonWidth) / kTabBarMinTabWidth;
tabWidth = (width - kTabBarNewTabButtonWidth) / visibleTabCount;
} else if(tabWidth > kTabBarMaxTabWidth) {
tabWidth = kTabBarMaxTabWidth;
visibleTabCount = tabCount;
} else {
visibleTabCount = tabCount;
}
} else {
tabWidth = kTabBarMaxTabWidth;
}
currentTabWidth = tabWidth;
// 拖动结束后,将xOffset转换为firstLeftTab;关闭标签页和旋转后,也需要重新计算
if (action == SWBTabBarActionMoveEnded || action == SWBTabBarActionClose || action == SWBTabBarActionNone) {
firstLeftTab = firstLeftTab - (xOffset - tabWidth / 2) / tabWidth;
if (firstLeftTab < 0) {
firstLeftTab = 0;
} else if(firstLeftTab > tabCount - visibleTabCount) {
firstLeftTab = tabCount - visibleTabCount;
}
xOffset = 0;
}
// 新建标签页后,滚动到最右边
else if (action == SWBTabBarActionNew) {
if (tabCount > visibleTabCount) {
firstLeftTab = tabCount - visibleTabCount;
}
}
xOffset -= firstLeftTab * tabWidth;
if (xOffset > 0) {
// 如果偏移小于最左边,将多出来的拖动距离减半
if(action == SWBTabBarActionMoving) {
xOffset /= 2;
} else {
xOffset = 0;
}
// 1/(x+1)的积分
// xOffset = 200 * log1pf(xOffset / 200);
#ifdef DEBUG
// NSLog(@"%f", xOffset);
#endif
} else if(xOffset + tabWidth * tabCount < visibleTabCount * tabWidth) {
// 如果偏移多于最右边,将多出来的距离减半
CGFloat overflow = visibleTabCount * tabWidth - (tabCount * tabWidth + xOffset);
#ifdef DEBUG
// NSLog(@"%f", overflow);
#endif
if(action == SWBTabBarActionMoving) {
xOffset = xOffset + overflow / 2;
} else {
xOffset = xOffset + overflow;
}
// xOffset = (width - kTabBarNewTabButtonWidth - (xOffset + tabWidth * tabCount)) / 2 + tabCount * tabWidth;
}
if (action == SWBTabBarActionInit) {
for (int i = 0; i < visibleTabCount; i++) {
SWBTabView *tabView = [[SWBTabView alloc] initWithFrame:CGRectMake((int)(xOffset + i * tabWidth - kTabBarTabInset / 2), 0, tabWidth + kTabBarTabInset, height)];
tabView.tag = i;
[self initANewTabView:tabView];
}
}
SWBTabView *tabViewToChange;
if (action == SWBTabBarActionNew) {
tabViewToChange = [[SWBTabView alloc] initWithFrame:CGRectMake((int)(xOffset + (tabCount - 1) * tabWidth - kTabBarTabInset / 2), -height, tabWidth + kTabBarTabInset, height)];
tabViewToChange.tag = [(SWBTab *)tabs[(tabCount - 1)] tag];
[self initANewTabView:tabViewToChange];
}
// 调整正在被拖的标签页的位置
if (action == SWBTabBarActionDraggingTab){
CGFloat draggingTabOffset = draggingTabLocationCurrentX - draggingTabLocationStartX;
CGFloat draggingTabViewX = xOffset + (draggingIndexFrom * tabWidth - kTabBarTabInset / 2);
SWBTabView *currentTabView = [self tabViewByTag:currentDraggingTab.tag];
currentTabView.frame = CGRectMake(draggingTabViewX + draggingTabOffset, 0, tabWidth + kTabBarTabInset, height);
}
if (animated) {
[UIView beginAnimations:@"layoutTabs" context:NULL];
// 进行额外的动画起始化设置
}
// 设置所有tabview的位置
if (action == SWBTabBarActionNone || action == SWBTabBarActionNew || action == SWBTabBarActionClose || action == SWBTabBarActionMoving || action == SWBTabBarActionMoveEnded || action == SWBTabBarActionDragTabEnded) {
int tabViewCount = [tabViews count];
for (int i = 0; i < tabViewCount; i++) {
SWBTabView *tabView = tabViews[i];
tabView.frame = CGRectMake((int)(xOffset + i * tabWidth - kTabBarTabInset / 2), 0, tabWidth + kTabBarTabInset, height);
}
}
// 设置除了被拖的标签页之外所有tabview的位置
if (action == SWBTabBarActionDraggingTab) {
int tabViewCount = [tabViews count];
for (int i = 0; i < tabViewCount; i++) {
SWBTabView *tabView = tabViews[i];
if (tabView.tag != currentDraggingTab.tag) {
tabView.frame = CGRectMake((int)(xOffset + i * tabWidth - kTabBarTabInset / 2), 0, tabWidth + kTabBarTabInset, height);
}
}
}
// 改变右边溢出的标签的透明度
if (action == SWBTabBarActionMoving || action == SWBTabBarActionMoveEnded || action == SWBTabBarActionDraggingTab || action == SWBTabBarActionDragTabEnded || action == SWBTabBarActionClose || action == SWBTabBarActionNew || action == SWBTabBarActionNone){
// if (action == SWBTabBarActionMoving) {
[UIView beginAnimations:@"tabbar change alpha" context:NULL];
// }
int tabViewCount = [tabViews count];
for (int i = 0; i < tabViewCount; i++) {
SWBTabView *tabView = tabViews[i];
if (tabView.tag != currentDraggingTab.tag) {
if (tabView.frame.origin.x + tabView.frame.size.width / 2 > width - kTabBarNewTabButtonWidth) {
tabView.alpha = kTabBarOverflowTabAlpha;
} else {
tabView.alpha = 1;
}
}
}
// if (action == SWBTabBarActionMoving) {
[UIView commitAnimations];
// }
}
//移动new tab按钮
if (action == SWBTabBarActionNew || action == SWBTabBarActionClose || action == SWBTabBarActionInit || action == SWBTabBarActionNone) {
// 延长按钮宽度
CGFloat newTabButtonWidth = width - visibleTabCount * tabWidth;
newTabButton.frame = CGRectMake(visibleTabCount * tabWidth, 0, newTabButtonWidth, self.bounds.size.height);
}
//将屏幕外的tabview隐藏
{
BOOL tabViewAdded = NO;
int tabViewCount = [tabViews count];
for (int i = 0; i < tabViewCount; i++) {
SWBTabView *tabView = tabViews[i];
if (tabView.frame.origin.x + tabView.frame.size.width < 0 ||
tabView.frame.origin.x > width) {
// tabView.hidden = YES;
[tabView removeFromSuperview];
} else {
// tabView.hidden = NO;
if (!tabView.superview) {
[self addSubview:tabView];
tabViewAdded = YES;
}
}
}
if (tabViewAdded) {
[self reorderTabViews];
}
}
if (action == SWBTabBarActionDraggingTab) {
[self tabViewByTag: currentDraggingTab.tag].alpha = kTabBarDraggingTabAlpha;
} else if (action == SWBTabBarActionDragTabEnded) {
[self tabViewByTag: currentDraggingTab.tag].alpha = 1;
}
if (animated) {
[UIView commitAnimations];
}
// [self moveNewTabButtonToTop];
}
-(void)layoutSubviews {
[super layoutSubviews];
CGFloat newWidth = self.bounds.size.width;
if (newWidth != lastWidth) {
[self layoutTabsWithAction:SWBTabBarActionNone animated:NO];
}
lastWidth = newWidth;
}
#pragma mark tabs handling
-(NSInteger)getNewTag {
return currentMaxTag++;
}
-(SWBTab *)newTab{
SWBTab *tab = [[SWBTab alloc] initWithTag:[self getNewTag]];
[tabs addObject:tab];
[self layoutTabsWithAction:SWBTabBarActionNew animated:YES];
return tab;
}
-(void)closeTab:(SWBTab *)tab animated:(BOOL)animated {
SWBTabView *tabView = [self tabViewByTag:tab.tag];
// 如果关闭的是当前标签页,选中下一个标签页,如果右边没有,选中左边的
if (currentTab == tab) {
NSInteger index = [tabs indexOfObject:tab];
if ([tabs count] != 1) {
if (index == [tabs count] - 1) {
// 如果就是最后一个,选左边的
if (index != 0) {
self.currentTab = tabs[(index - 1)];
}
} else {
self.currentTab = tabs[(index + 1)];
}
} else {
self.currentTab = nil;
}
}
[tabs removeObject:tab];
[self removeATabView:tabView];
[self layoutTabsWithAction:SWBTabBarActionClose animated:YES];
[delegate tabBarViewTabDidClose:tab];
}
-(void)setCurrentTab:(SWBTab *)newCurrentTab {
if (newCurrentTab == currentTab) {
return;
}
if (newCurrentTab) {
//TODO: set old current tab to a non-top status
for (int i = 0; i < [tabs count]; i++) {
SWBTab *tab = tabs[i];
if (tab == currentTab) {
for (SWBTabView *tabView in tabViews) {
if (tabView.tag == tab.tag) {
tabView.focused = NO;
break;
}
}
} else if(tab == newCurrentTab) {
// SWBTabView *tabViewFound = nil;
for (SWBTabView *tabView in tabViews) {
if (tabView.tag == tab.tag) {
tabView.focused = YES;
// tabViewFound = tabView;
break;
}
}
}
}
}
currentTab = newCurrentTab;
[self reorderTabViews];
if (newCurrentTab) {
[delegate tabBarViewTabDidSelect:currentTab];
}
}
-(void)setCurrentTabWithTag:(NSInteger)tag {
[self setCurrentTab:[self tabByTag:tag]];
}
-(void)newTabButtonClicked {
[delegate tabBarViewNewTabButtonDidClick];
}
-(void)tabClicked:(id)sender {
SWBTabView *tabView = sender;
self.currentTab = [self tabByTag:tabView.tag];
}
-(void)tabViewDidClickCloseButton:(id)sender {
SWBTabView *tabView = sender;
SWBTab *tab = [self tabByTag:tabView.tag];
[self closeTab:tab animated:YES];
}
#pragma mark gesture handling
- (void)handlePanGesture:(UIGestureRecognizer *)gestureRecognizer {
CGPoint point = [(UIPanGestureRecognizer *)gestureRecognizer translationInView:self];
UIGestureRecognizerState state = [(UIPanGestureRecognizer *)gestureRecognizer state];
if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStateChanged) {
movingOffset = point.x;
[self layoutTabsWithAction:SWBTabBarActionMoving animated:NO];
} else if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled) {
[self layoutTabsWithAction:SWBTabBarActionMoveEnded animated:YES];
movingOffset = 0;
}
#ifdef DEBUG
// NSLog(@"pan %@", gestureRecognizer.view);
// NSLog(@"%f", point.x);
#endif
}
- (void)handleLongPressGesture:(UIGestureRecognizer *)gestureRecognizer {
SWBTabView *tabView = (SWBTabView *)gestureRecognizer.view;
currentDraggingTab = [self tabByTag:tabView.tag];
CGFloat currentPointX = [(UILongPressGestureRecognizer *)gestureRecognizer locationInView:self].x;
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
// 记录开始拖动时的信息
draggingTabLocationStartX = currentPointX;
draggingIndexFrom = [tabs indexOfObject:currentDraggingTab];
[self reorderTabViews];
[UIView beginAnimations:@"dragging tab view alpha" context:NULL];
tabView.alpha = kTabBarDraggingTabAlpha;
[UIView commitAnimations];
} else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) {
draggingTabLocationCurrentX = currentPointX;
// 调整被拖动的标签页的index
NSInteger newIndex = [self indexForPosition:currentPointX];
NSInteger tabsCount = [tabs count];
if (newIndex < 0) {
newIndex = 0;
} else if(newIndex > tabsCount - 1) {
newIndex = tabsCount - 1;
}
NSInteger oldIndex = [tabs indexOfObject:currentDraggingTab];
if (oldIndex != newIndex) {
[tabs removeObject:currentDraggingTab];
[tabs insertObject:currentDraggingTab atIndex:newIndex];
#ifdef DEBUG
// NSLog(@"move tab to index %d", newIndex);
#endif
[tabViews removeObject:tabView];
[tabViews insertObject:tabView atIndex:newIndex];
[delegate tabBarViewTabDidMove:currentDraggingTab toIndex:newIndex];
}
[self layoutTabsWithAction:SWBTabBarActionDraggingTab animated:YES];
} else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
[self layoutTabsWithAction:SWBTabBarActionDragTabEnded animated:YES];
currentDraggingTab = nil;
[self reorderTabViews];
}
#ifdef DEBUG
// NSLog(@"long press %@", gestureRecognizer.view);
// // NSLog(@"%f", firstPoint.x);
// NSLog(@"%f", currentPointX);
#endif
}
-(void)setTitleForTab:(NSInteger)tag title:(NSString *)theTitle{
[self tabViewByTag:tag].title = theTitle;
}
-(void)setLoadingForTab:(NSInteger)tag loading:(BOOL)loading {
[self tabViewByTag:tag].loading = loading;
}
#pragma mark settings changed
-(void)settingsChanged {
// TODO
// BOOL showEnd = [appSettingsManager showEndOfTheTitle];
BOOL showEnd = NO;
for (SWBTabView *tabView in tabViews) {
tabView.titleLabel.lineBreakMode = showEnd? NSLineBreakByTruncatingMiddle:NSLineBreakByTruncatingTail;
}
}
#pragma mark dealloc
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
for (SWBTabView *tabView in tabViews) {
[self removeATabView:tabView];
}
[newTabButton removeTarget:self action:@selector(newTabButtonClicked) forControlEvents:UIControlEventTouchUpInside];
}
@end