Geen omschrijving

SGPageTitleView.m 49KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. //
  2. // 如遇到问题或有更好方案,请通过以下方式进行联系
  3. // QQ群:429899752
  4. // Email:kingsic@126.com
  5. // GitHub:https://github.com/kingsic/SGPagingView
  6. //
  7. // SGPageTitleView.m
  8. // SGPagingViewExample
  9. //
  10. // Created by kingsic on 17/4/10.
  11. // Copyright © 2017年 kingsic. All rights reserved.
  12. //
  13. #import "SGPageTitleView.h"
  14. #import "UIView+SGPagingView.h"
  15. #import "SGPageTitleViewConfigure.h"
  16. #define SGPageTitleViewWidth self.frame.size.width
  17. #define SGPageTitleViewHeight self.frame.size.height
  18. #pragma mark - - - SGPageTitleButton
  19. @interface SGPageTitleButton : UIButton
  20. @end
  21. @implementation SGPageTitleButton
  22. - (void)setHighlighted:(BOOL)highlighted {
  23. }
  24. @end
  25. #pragma mark - - - SGPageTitleView
  26. @interface SGPageTitleView ()
  27. /// SGPageTitleViewDelegate
  28. @property (nonatomic, weak) id<SGPageTitleViewDelegate> delegatePageTitleView;
  29. /// SGPageTitleView 配置信息
  30. @property (nonatomic, readwrite, strong) SGPageTitleViewConfigure *configure;
  31. /// scrollView
  32. @property (nonatomic, strong) UIScrollView *scrollView;
  33. /// 指示器
  34. @property (nonatomic, strong) UIView *indicatorView;
  35. /// 底部分割线
  36. @property (nonatomic, strong) UIView *bottomSeparator;
  37. /// 保存外界传递过来的标题数组
  38. @property (nonatomic, strong) NSArray *titleArr;
  39. /// 存储标题按钮的数组
  40. @property (nonatomic, strong) NSMutableArray *btnMArr;
  41. /// tempBtn
  42. @property (nonatomic, strong) UIButton *tempBtn;
  43. /// 记录所有按钮文字宽度
  44. @property (nonatomic, assign) CGFloat allBtnTextWidth;
  45. /// 记录所有子控件的宽度
  46. @property (nonatomic, assign) CGFloat allBtnWidth;
  47. /// 标记按钮下标
  48. @property (nonatomic, assign) NSInteger signBtnIndex;
  49. /// 开始颜色, 取值范围 0~1
  50. @property (nonatomic, assign) CGFloat startR;
  51. @property (nonatomic, assign) CGFloat startG;
  52. @property (nonatomic, assign) CGFloat startB;
  53. /// 完成颜色, 取值范围 0~1
  54. @property (nonatomic, assign) CGFloat endR;
  55. @property (nonatomic, assign) CGFloat endG;
  56. @property (nonatomic, assign) CGFloat endB;
  57. @end
  58. @implementation SGPageTitleView
  59. - (instancetype)initWithFrame:(CGRect)frame delegate:(id<SGPageTitleViewDelegate>)delegate titleNames:(NSArray *)titleNames configure:(SGPageTitleViewConfigure *)configure {
  60. if (self = [super initWithFrame:frame]) {
  61. self.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.77];
  62. if (delegate == nil) {
  63. @throw [NSException exceptionWithName:@"SGPagingView" reason:@"SGPageTitleView 的代理方法必须设置" userInfo:nil];
  64. }
  65. self.delegatePageTitleView = delegate;
  66. if (titleNames == nil) {
  67. @throw [NSException exceptionWithName:@"SGPagingView" reason:@"SGPageTitleView 的标题数组必须设置" userInfo:nil];
  68. }
  69. self.titleArr = titleNames;
  70. if (configure == nil) {
  71. @throw [NSException exceptionWithName:@"SGPagingView" reason:@"SGPageTitleView 的配置属性必须设置" userInfo:nil];
  72. }
  73. self.configure = configure;
  74. [self initialization];
  75. [self setupSubviews];
  76. }
  77. return self;
  78. }
  79. + (instancetype)pageTitleViewWithFrame:(CGRect)frame delegate:(id<SGPageTitleViewDelegate>)delegate titleNames:(NSArray *)titleNames configure:(SGPageTitleViewConfigure *)configure {
  80. return [[self alloc] initWithFrame:frame delegate:delegate titleNames:titleNames configure:configure];
  81. }
  82. - (void)initialization {
  83. _isTitleGradientEffect = YES;
  84. _isOpenTitleTextZoom = NO;
  85. _isShowIndicator = YES;
  86. _isNeedBounces = YES;
  87. _isShowBottomSeparator = YES;
  88. _selectedIndex = 0;
  89. _titleTextScaling = 0.1;
  90. }
  91. - (void)setupSubviews {
  92. // 0、处理偏移量
  93. UIView *tempView = [[UIView alloc] initWithFrame:CGRectZero];
  94. [self addSubview:tempView];
  95. // 1、添加 UIScrollView
  96. [self addSubview:self.scrollView];
  97. // 2、添加标题按钮
  98. [self setupTitleButtons];
  99. // 3、添加底部分割线
  100. [self addSubview:self.bottomSeparator];
  101. // 4、添加指示器
  102. [self.scrollView insertSubview:self.indicatorView atIndex:0];
  103. }
  104. #pragma mark - - - layoutSubviews
  105. - (void)layoutSubviews {
  106. [super layoutSubviews];
  107. // 选中按钮下标初始值
  108. UIButton *lastBtn = self.btnMArr.lastObject;
  109. if (lastBtn.tag >= _selectedIndex && _selectedIndex >= 0) {
  110. [self P_btn_action:self.btnMArr[_selectedIndex]];
  111. } else {
  112. return;
  113. }
  114. }
  115. #pragma mark - - - 懒加载
  116. - (NSArray *)titleArr {
  117. if (!_titleArr) {
  118. _titleArr = [NSArray array];
  119. }
  120. return _titleArr;
  121. }
  122. - (NSMutableArray *)btnMArr {
  123. if (!_btnMArr) {
  124. _btnMArr = [NSMutableArray array];
  125. }
  126. return _btnMArr;
  127. }
  128. - (UIScrollView *)scrollView {
  129. if (!_scrollView) {
  130. _scrollView = [[UIScrollView alloc] init];
  131. _scrollView.showsVerticalScrollIndicator = NO;
  132. _scrollView.showsHorizontalScrollIndicator = NO;
  133. _scrollView.alwaysBounceHorizontal = YES;
  134. _scrollView.frame = CGRectMake(0, 0, SGPageTitleViewWidth, SGPageTitleViewHeight);
  135. }
  136. return _scrollView;
  137. }
  138. - (UIView *)indicatorView {
  139. if (!_indicatorView) {
  140. _indicatorView = [[UIView alloc] init];
  141. if (self.configure.indicatorStyle == SGIndicatorStyleCover) {
  142. CGFloat tempIndicatorViewH = [self SG_heightWithString:[self.btnMArr[0] currentTitle] font:self.configure.titleFont];
  143. if (self.configure.indicatorHeight > self.SG_height) {
  144. _indicatorView.SG_y = 0;
  145. _indicatorView.SG_height = self.SG_height;
  146. } else if (self.configure.indicatorHeight < tempIndicatorViewH) {
  147. _indicatorView.SG_y = 0.5 * (self.SG_height - tempIndicatorViewH);
  148. _indicatorView.SG_height = tempIndicatorViewH;
  149. } else {
  150. _indicatorView.SG_y = 0.5 * (self.SG_height - self.configure.indicatorHeight);
  151. _indicatorView.SG_height = self.configure.indicatorHeight;
  152. }
  153. // 圆角处理
  154. if (self.configure.indicatorCornerRadius > 0.5 * _indicatorView.SG_height) {
  155. _indicatorView.layer.cornerRadius = 0.5 * _indicatorView.SG_height;
  156. } else {
  157. _indicatorView.layer.cornerRadius = self.configure.indicatorCornerRadius;
  158. }
  159. // 边框宽度及边框颜色
  160. _indicatorView.layer.borderWidth = self.configure.indicatorBorderWidth;
  161. _indicatorView.layer.borderColor = self.configure.indicatorBorderColor.CGColor;
  162. } else {
  163. CGFloat indicatorViewH = self.configure.indicatorHeight;
  164. _indicatorView.SG_height = indicatorViewH;
  165. _indicatorView.SG_y = self.SG_height - indicatorViewH;
  166. }
  167. _indicatorView.backgroundColor = self.configure.indicatorColor;
  168. }
  169. return _indicatorView;
  170. }
  171. - (UIView *)bottomSeparator {
  172. if (!_bottomSeparator) {
  173. _bottomSeparator = [[UIView alloc] init];
  174. CGFloat bottomSeparatorW = self.SG_width;
  175. CGFloat bottomSeparatorH = 0.5;
  176. CGFloat bottomSeparatorX = 0;
  177. CGFloat bottomSeparatorY = self.SG_height - bottomSeparatorH;
  178. _bottomSeparator.frame = CGRectMake(bottomSeparatorX, bottomSeparatorY, bottomSeparatorW, bottomSeparatorH);
  179. _bottomSeparator.backgroundColor = [UIColor lightGrayColor];
  180. }
  181. return _bottomSeparator;
  182. }
  183. #pragma mark - - - 计算字符串宽度
  184. - (CGFloat)SG_widthWithString:(NSString *)string font:(UIFont *)font {
  185. NSDictionary *attrs = @{NSFontAttributeName : font};
  186. return [string boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.width;
  187. }
  188. #pragma mark - - - 计算字符串高度
  189. - (CGFloat)SG_heightWithString:(NSString *)string font:(UIFont *)font {
  190. NSDictionary *attrs = @{NSFontAttributeName : font};
  191. return [string boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.height;
  192. }
  193. #pragma mark - - - 添加标题按钮
  194. - (void)setupTitleButtons {
  195. // 计算所有按钮的文字宽度
  196. [self.titleArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  197. CGFloat tempWidth = [self SG_widthWithString:obj font:self.configure.titleFont];
  198. self.allBtnTextWidth += tempWidth;
  199. }];
  200. // 所有按钮文字宽度 + 按钮之间的间隔
  201. self.allBtnWidth = self.configure.spacingBetweenButtons * (self.titleArr.count + 1) + self.allBtnTextWidth;
  202. self.allBtnWidth = ceilf(self.allBtnWidth);
  203. NSInteger titleCount = self.titleArr.count;
  204. if (self.allBtnWidth <= self.bounds.size.width) { // SGPageTitleView 静止样式
  205. CGFloat btnY = 0;
  206. CGFloat btnW = SGPageTitleViewWidth / self.titleArr.count;
  207. CGFloat btnH = 0;
  208. if (self.configure.indicatorStyle == SGIndicatorStyleDefault) {
  209. btnH = SGPageTitleViewHeight - self.configure.indicatorHeight;
  210. } else {
  211. btnH = SGPageTitleViewHeight;
  212. }
  213. for (NSInteger index = 0; index < titleCount; index++) {
  214. SGPageTitleButton *btn = [[SGPageTitleButton alloc] init];
  215. CGFloat btnX = btnW * index;
  216. btn.frame = CGRectMake(btnX, btnY, btnW, btnH);
  217. btn.tag = index;
  218. btn.titleLabel.font = self.configure.titleFont;
  219. [btn setTitle:self.titleArr[index] forState:(UIControlStateNormal)];
  220. [btn setTitleColor:self.configure.titleColor forState:(UIControlStateNormal)];
  221. [btn setTitleColor:self.configure.titleSelectedColor forState:(UIControlStateSelected)];
  222. [btn addTarget:self action:@selector(P_btn_action:) forControlEvents:(UIControlEventTouchUpInside)];
  223. [self.btnMArr addObject:btn];
  224. [self.scrollView addSubview:btn];
  225. [self setupStartColor:self.configure.titleColor];
  226. [self setupEndColor:self.configure.titleSelectedColor];
  227. }
  228. self.scrollView.contentSize = CGSizeMake(SGPageTitleViewWidth, SGPageTitleViewHeight);
  229. } else { // SGPageTitleView 滚动样式
  230. CGFloat btnX = 0;
  231. CGFloat btnY = 0;
  232. CGFloat btnH = 0;
  233. if (self.configure.indicatorStyle == SGIndicatorStyleDefault) {
  234. btnH = SGPageTitleViewHeight - self.configure.indicatorHeight;
  235. } else {
  236. btnH = SGPageTitleViewHeight;
  237. }
  238. for (NSInteger index = 0; index < titleCount; index++) {
  239. SGPageTitleButton *btn = [[SGPageTitleButton alloc] init];
  240. CGFloat btnW = [self SG_widthWithString:self.titleArr[index] font:self.configure.titleFont] + self.configure.spacingBetweenButtons;
  241. btn.frame = CGRectMake(btnX, btnY, btnW, btnH);
  242. btnX = btnX + btnW;
  243. btn.tag = index;
  244. btn.titleLabel.font = self.configure.titleFont;
  245. [btn setTitle:self.titleArr[index] forState:(UIControlStateNormal)];
  246. [btn setTitleColor:self.configure.titleColor forState:(UIControlStateNormal)];
  247. [btn setTitleColor:self.configure.titleSelectedColor forState:(UIControlStateSelected)];
  248. [btn addTarget:self action:@selector(P_btn_action:) forControlEvents:(UIControlEventTouchUpInside)];
  249. [self.btnMArr addObject:btn];
  250. [self.scrollView addSubview:btn];
  251. [self setupStartColor:self.configure.titleColor];
  252. [self setupEndColor:self.configure.titleSelectedColor];
  253. }
  254. CGFloat scrollViewWidth = CGRectGetMaxX(self.scrollView.subviews.lastObject.frame);
  255. self.scrollView.contentSize = CGSizeMake(scrollViewWidth, SGPageTitleViewHeight);
  256. }
  257. }
  258. #pragma mark - - - 标题按钮的点击事件
  259. - (void)P_btn_action:(UIButton *)button {
  260. // 1、改变按钮的选择状态
  261. [self P_changeSelectedButton:button];
  262. // 2、滚动标题选中按钮居中
  263. if (self.allBtnWidth > SGPageTitleViewWidth) {
  264. [self P_selectedBtnCenter:button];
  265. }
  266. // 3、改变指示器的位置以及指示器宽度样式
  267. [self P_changeIndicatorViewLocationWithButton:button];
  268. // 4、pageTitleViewDelegate
  269. if ([self.delegatePageTitleView respondsToSelector:@selector(pageTitleView:selectedIndex:)]) {
  270. [self.delegatePageTitleView pageTitleView:self selectedIndex:button.tag];
  271. }
  272. // 5、标记按钮下标
  273. self.signBtnIndex = button.tag;
  274. }
  275. - (void)c_btn_action:(UIButton *)button {
  276. // 1、改变按钮的选择状态
  277. [self P_changeSelectedButton:button];
  278. // 2、滚动标题选中按钮居中
  279. if (self.allBtnWidth > SGPageTitleViewWidth) {
  280. [self P_selectedBtnCenter:button];
  281. }
  282. // 3、改变指示器的位置以及指示器宽度样式
  283. [self P_changeIndicatorViewLocationWithButton:button];
  284. // 4、pageTitleViewDelegate
  285. // 5、标记按钮下标
  286. self.signBtnIndex = button.tag;
  287. }
  288. #pragma mark - - - 改变按钮的选择状态
  289. - (void)P_changeSelectedButton:(UIButton *)button {
  290. if (self.tempBtn == nil) {
  291. button.selected = YES;
  292. self.tempBtn = button;
  293. } else if (self.tempBtn != nil && self.tempBtn == button){
  294. button.selected = YES;
  295. } else if (self.tempBtn != button && self.tempBtn != nil){
  296. self.tempBtn.selected = NO;
  297. button.selected = YES;
  298. self.tempBtn = button;
  299. }
  300. // 标题文字缩放属性
  301. if (self.isOpenTitleTextZoom) {
  302. [self.btnMArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  303. UIButton *btn = obj;
  304. btn.transform = CGAffineTransformMakeScale(1, 1);
  305. }];
  306. button.transform = CGAffineTransformMakeScale(1 + self.titleTextScaling, 1 + self.titleTextScaling);
  307. }
  308. }
  309. #pragma mark - - - 滚动标题选中按钮居中
  310. - (void)P_selectedBtnCenter:(UIButton *)centerBtn {
  311. // 计算偏移量
  312. CGFloat offsetX = centerBtn.center.x - SGPageTitleViewWidth * 0.5;
  313. if (offsetX < 0) offsetX = 0;
  314. // 获取最大滚动范围
  315. CGFloat maxOffsetX = self.scrollView.contentSize.width - SGPageTitleViewWidth;
  316. if (offsetX > maxOffsetX) offsetX = maxOffsetX;
  317. // 滚动标题滚动条
  318. [self.scrollView setContentOffset:CGPointMake(offsetX, 0) animated:YES];
  319. }
  320. #pragma mark - - - 改变指示器的位置以及指示器宽度样式
  321. - (void)P_changeIndicatorViewLocationWithButton:(UIButton *)button {
  322. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  323. if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  324. self.indicatorView.SG_width = self.configure.indicatorFixedWidth;
  325. self.indicatorView.SG_centerX = button.SG_centerX;
  326. } else if (self.configure.indicatorStyle == SGIndicatorStyleDynamic) {
  327. self.indicatorView.SG_width = self.configure.indicatorDynamicWidth;
  328. self.indicatorView.SG_centerX = button.SG_centerX;
  329. } else {
  330. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:button.currentTitle font:self.configure.titleFont];
  331. if (tempIndicatorWidth > button.SG_width) {
  332. tempIndicatorWidth = button.SG_width;
  333. }
  334. self.indicatorView.SG_width = tempIndicatorWidth;
  335. self.indicatorView.SG_centerX = button.SG_centerX;
  336. }
  337. }];
  338. }
  339. #pragma mark - - - 给外界提供的方法
  340. - (void)setPageTitleViewWithProgress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
  341. // 1、取出 originalBtn/targetBtn
  342. UIButton *originalBtn = self.btnMArr[originalIndex];
  343. UIButton *targetBtn = self.btnMArr[targetIndex];
  344. self.signBtnIndex = targetBtn.tag;
  345. // 2、 滚动标题选中居中
  346. [self P_selectedBtnCenter:targetBtn];
  347. // 3、处理指示器的逻辑
  348. if (self.allBtnWidth <= self.bounds.size.width) { /// SGPageTitleView 不可滚动
  349. if (self.configure.indicatorScrollStyle == SGIndicatorScrollStyleDefault) {
  350. [self P_smallIndicatorScrollStyleDefaultWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
  351. } else {
  352. [self P_smallIndicatorScrollStyleHalfEndWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
  353. }
  354. } else { /// SGPageTitleView 可滚动
  355. if (self.configure.indicatorScrollStyle == SGIndicatorScrollStyleDefault) {
  356. [self P_indicatorScrollStyleDefaultWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
  357. } else {
  358. [self P_indicatorScrollStyleHalfEndWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
  359. }
  360. }
  361. // 4、颜色的渐变(复杂)
  362. if (self.isTitleGradientEffect) {
  363. [self P_isTitleGradientEffectWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
  364. }
  365. // 5 、标题文字缩放属性
  366. if (self.isOpenTitleTextZoom) {
  367. // 左边缩放
  368. originalBtn.transform = CGAffineTransformMakeScale((1 - progress) * self.titleTextScaling + 1, (1 - progress) * self.titleTextScaling + 1);
  369. // 右边缩放
  370. targetBtn.transform = CGAffineTransformMakeScale(progress * self.titleTextScaling + 1, progress * self.titleTextScaling + 1);
  371. }
  372. }
  373. /**
  374. * 根据下标重置标题文字
  375. *
  376. * @param index 标题所对应的下标
  377. * @param title 新标题名
  378. */
  379. - (void)resetTitleWithIndex:(NSInteger)index newTitle:(NSString *)title {
  380. if (index < self.btnMArr.count) {
  381. UIButton *button = (UIButton *)self.btnMArr[index];
  382. [button setTitle:title forState:UIControlStateNormal];
  383. if (self.signBtnIndex == index) {
  384. if (self.configure.indicatorStyle == SGIndicatorStyleDefault || self.configure.indicatorStyle == SGIndicatorStyleCover) {
  385. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:button.currentTitle font:self.configure.titleFont];
  386. if (tempIndicatorWidth > button.SG_width) {
  387. tempIndicatorWidth = button.SG_width;
  388. }
  389. self.indicatorView.SG_width = tempIndicatorWidth;
  390. self.indicatorView.SG_centerX = button.SG_centerX;
  391. }
  392. }
  393. }
  394. }
  395. #pragma mark - - - SGPageTitleView 静止样式下指示器默认滚动样式(SGIndicatorScrollStyleDefault)
  396. - (void)P_smallIndicatorScrollStyleDefaultWithProgress:(CGFloat)progress originalBtn:(UIButton *)originalBtn targetBtn:(UIButton *)targetBtn {
  397. // 1、改变按钮的选择状态
  398. if (progress >= 0.8) { /// 此处取 >= 0.8 而不是 1.0 为的是防止用户滚动过快而按钮的选中状态并没有改变
  399. [self P_changeSelectedButton:targetBtn];
  400. }
  401. if (self.configure.indicatorStyle == SGIndicatorStyleDynamic) {
  402. NSInteger originalBtnTag = originalBtn.tag;
  403. NSInteger targetBtnTag = targetBtn.tag;
  404. // 按钮之间的距离
  405. CGFloat distance = self.SG_width / self.titleArr.count;
  406. if (originalBtnTag <= targetBtnTag) { // 往左滑
  407. if (progress <= 0.5) {
  408. self.indicatorView.SG_width = self.configure.indicatorDynamicWidth + 2 * progress * distance;
  409. } else {
  410. CGFloat targetBtnIndicatorX = CGRectGetMaxX(targetBtn.frame) - 0.5 * (distance - self.configure.indicatorDynamicWidth) - self.configure.indicatorDynamicWidth;
  411. self.indicatorView.SG_x = targetBtnIndicatorX + 2 * (progress - 1) * distance;
  412. self.indicatorView.SG_width = self.configure.indicatorDynamicWidth + 2 * (1 - progress) * distance;
  413. }
  414. } else {
  415. if (progress <= 0.5) {
  416. CGFloat originalBtnIndicatorX = CGRectGetMaxX(originalBtn.frame) - 0.5 * (distance - self.configure.indicatorDynamicWidth) - self.configure.indicatorDynamicWidth;
  417. self.indicatorView.SG_x = originalBtnIndicatorX - 2 * progress * distance;
  418. self.indicatorView.SG_width = self.configure.indicatorDynamicWidth + 2 * progress * distance;
  419. } else {
  420. CGFloat targetBtnIndicatorX = CGRectGetMaxX(targetBtn.frame) - self.configure.indicatorDynamicWidth - 0.5 * (distance - self.configure.indicatorDynamicWidth);
  421. self.indicatorView.SG_x = targetBtnIndicatorX; // 这句代码必须写,防止滚动结束之后指示器位置存在偏差,这里的偏差是由于 progress >= 0.8 导致的
  422. self.indicatorView.SG_width = self.configure.indicatorDynamicWidth + 2 * (1 - progress) * distance;
  423. }
  424. }
  425. } else if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  426. CGFloat targetBtnIndicatorX = CGRectGetMaxX(targetBtn.frame) - 0.5 * (self.SG_width / self.titleArr.count - self.configure.indicatorFixedWidth) - self.configure.indicatorFixedWidth;
  427. CGFloat originalBtnIndicatorX = CGRectGetMaxX(originalBtn.frame) - 0.5 * (self.SG_width / self.titleArr.count - self.configure.indicatorFixedWidth) - self.configure.indicatorFixedWidth;
  428. CGFloat totalOffsetX = targetBtnIndicatorX - originalBtnIndicatorX;
  429. self.indicatorView.SG_x = originalBtnIndicatorX + progress * totalOffsetX;
  430. } else {
  431. /// 1、计算 indicator 偏移量
  432. // targetBtn 文字宽度
  433. CGFloat targetBtnTextWidth = [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  434. CGFloat targetBtnIndicatorX = CGRectGetMaxX(targetBtn.frame) - targetBtnTextWidth - 0.5 * (self.SG_width / self.titleArr.count - targetBtnTextWidth + self.configure.indicatorAdditionalWidth);
  435. // originalBtn 文字宽度
  436. CGFloat originalBtnTextWidth = [self SG_widthWithString:originalBtn.currentTitle font:self.configure.titleFont];
  437. CGFloat originalBtnIndicatorX = CGRectGetMaxX(originalBtn.frame) - originalBtnTextWidth - 0.5 * (self.SG_width / self.titleArr.count - originalBtnTextWidth + self.configure.indicatorAdditionalWidth);
  438. CGFloat totalOffsetX = targetBtnIndicatorX - originalBtnIndicatorX;
  439. /// 2、计算文字之间差值
  440. // 按钮宽度的距离
  441. CGFloat btnWidth = self.SG_width / self.titleArr.count;
  442. // targetBtn 文字右边的 x 值
  443. CGFloat targetBtnRightTextX = CGRectGetMaxX(targetBtn.frame) - 0.5 * (btnWidth - targetBtnTextWidth);
  444. // originalBtn 文字右边的 x 值
  445. CGFloat originalBtnRightTextX = CGRectGetMaxX(originalBtn.frame) - 0.5 * (btnWidth - originalBtnTextWidth);
  446. CGFloat totalRightTextDistance = targetBtnRightTextX - originalBtnRightTextX;
  447. // 计算 indicatorView 滚动时 x 的偏移量
  448. CGFloat offsetX = totalOffsetX * progress;
  449. // 计算 indicatorView 滚动时文字宽度的偏移量
  450. CGFloat distance = progress * (totalRightTextDistance - totalOffsetX);
  451. /// 3、计算 indicatorView 新的 frame
  452. self.indicatorView.SG_x = originalBtnIndicatorX + offsetX;
  453. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + originalBtnTextWidth + distance;
  454. if (tempIndicatorWidth >= targetBtn.SG_width) {
  455. CGFloat moveTotalX = targetBtn.SG_origin.x - originalBtn.SG_origin.x;
  456. CGFloat moveX = moveTotalX * progress;
  457. self.indicatorView.SG_centerX = originalBtn.SG_centerX + moveX;
  458. } else {
  459. self.indicatorView.SG_width = tempIndicatorWidth;
  460. }
  461. }
  462. }
  463. #pragma mark - - - SGPageTitleView 滚动样式下指示器默认滚动样式(SGIndicatorScrollStyleDefault)
  464. - (void)P_indicatorScrollStyleDefaultWithProgress:(CGFloat)progress originalBtn:(UIButton *)originalBtn targetBtn:(UIButton *)targetBtn {
  465. /// 改变按钮的选择状态
  466. if (progress >= 0.8) { /// 此处取 >= 0.8 而不是 1.0 为的是防止用户滚动过快而按钮的选中状态并没有改变
  467. [self P_changeSelectedButton:targetBtn];
  468. }
  469. if (self.configure.indicatorStyle == SGIndicatorStyleDynamic) {
  470. NSInteger originalBtnTag = originalBtn.tag;
  471. NSInteger targetBtnTag = targetBtn.tag;
  472. if (originalBtnTag <= targetBtnTag) { // 往左滑
  473. // targetBtn 与 originalBtn 中心点之间的距离
  474. CGFloat btnCenterXDistance = targetBtn.SG_centerX - originalBtn.SG_centerX;
  475. if (progress <= 0.5) {
  476. self.indicatorView.SG_width = 2 * progress * btnCenterXDistance + self.configure.indicatorDynamicWidth;
  477. } else {
  478. CGFloat targetBtnX = CGRectGetMaxX(targetBtn.frame) - self.configure.indicatorDynamicWidth - 0.5 * (targetBtn.SG_width - self.configure.indicatorDynamicWidth);
  479. self.indicatorView.SG_x = targetBtnX + 2 * (progress - 1) * btnCenterXDistance;
  480. self.indicatorView.SG_width = 2 * (1 - progress) * btnCenterXDistance + self.configure.indicatorDynamicWidth;
  481. }
  482. } else {
  483. // originalBtn 与 targetBtn 中心点之间的距离
  484. CGFloat btnCenterXDistance = originalBtn.SG_centerX - targetBtn.SG_centerX;
  485. if (progress <= 0.5) {
  486. CGFloat originalBtnX = CGRectGetMaxX(originalBtn.frame) - self.configure.indicatorDynamicWidth - 0.5 * (originalBtn.SG_width - self.configure.indicatorDynamicWidth);
  487. self.indicatorView.SG_x = originalBtnX - 2 * progress * btnCenterXDistance;
  488. self.indicatorView.SG_width = 2 * progress * btnCenterXDistance + self.configure.indicatorDynamicWidth;
  489. } else {
  490. CGFloat targetBtnX = CGRectGetMaxX(targetBtn.frame) - self.configure.indicatorDynamicWidth - 0.5 * (targetBtn.SG_width - self.configure.indicatorDynamicWidth);
  491. self.indicatorView.SG_x = targetBtnX; // 这句代码必须写,防止滚动结束之后指示器位置存在偏差,这里的偏差是由于 progress >= 0.8 导致的
  492. self.indicatorView.SG_width = 2 * (1 - progress) * btnCenterXDistance + self.configure.indicatorDynamicWidth;
  493. }
  494. }
  495. } else if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  496. CGFloat targetBtnIndicatorX = CGRectGetMaxX(targetBtn.frame) - 0.5 * (targetBtn.SG_width - self.configure.indicatorFixedWidth) - self.configure.indicatorFixedWidth;
  497. CGFloat originalBtnIndicatorX = CGRectGetMaxX(originalBtn.frame) - self.configure.indicatorFixedWidth - 0.5 * (originalBtn.SG_width - self.configure.indicatorFixedWidth);
  498. CGFloat totalOffsetX = targetBtnIndicatorX - originalBtnIndicatorX;
  499. CGFloat offsetX = totalOffsetX * progress;
  500. self.indicatorView.SG_x = originalBtnIndicatorX + offsetX;
  501. } else {
  502. // 1、计算 targetBtn/originalBtn 之间的 x 差值
  503. CGFloat totalOffsetX = targetBtn.SG_origin.x - originalBtn.SG_origin.x;
  504. // 2、计算 targetBtn/originalBtn 之间的差值
  505. CGFloat totalDistance = CGRectGetMaxX(targetBtn.frame) - CGRectGetMaxX(originalBtn.frame);
  506. /// 计算 indicatorView 滚动时 x 的偏移量
  507. CGFloat offsetX = 0.0;
  508. /// 计算 indicatorView 滚动时宽度的偏移量
  509. CGFloat distance = 0.0;
  510. CGFloat targetBtnTextWidth = [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  511. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + targetBtnTextWidth;
  512. if (tempIndicatorWidth >= targetBtn.SG_width) {
  513. offsetX = totalOffsetX * progress;
  514. distance = progress * (totalDistance - totalOffsetX);
  515. self.indicatorView.SG_x = originalBtn.SG_origin.x + offsetX;
  516. self.indicatorView.SG_width = originalBtn.SG_width + distance;
  517. } else {
  518. offsetX = totalOffsetX * progress + 0.5 * self.configure.spacingBetweenButtons - 0.5 * self.configure.indicatorAdditionalWidth;
  519. distance = progress * (totalDistance - totalOffsetX) - self.configure.spacingBetweenButtons;
  520. /// 计算 indicatorView 新的 frame
  521. self.indicatorView.SG_x = originalBtn.SG_origin.x + offsetX;
  522. self.indicatorView.SG_width = originalBtn.SG_width + distance + self.configure.indicatorAdditionalWidth;
  523. }
  524. }
  525. }
  526. #pragma mark - - - SGPageTitleView 静止样式下指示器 SGIndicatorScrollStyleHalf 和 SGIndicatorScrollStyleEnd 滚动样式
  527. - (void)P_smallIndicatorScrollStyleHalfEndWithProgress:(CGFloat)progress originalBtn:(UIButton *)originalBtn targetBtn:(UIButton *)targetBtn {
  528. if (self.configure.indicatorScrollStyle == SGIndicatorScrollStyleHalf) {
  529. if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  530. if (progress >= 0.5) {
  531. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  532. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  533. [self P_changeSelectedButton:targetBtn];
  534. }];
  535. } else {
  536. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  537. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  538. [self P_changeSelectedButton:originalBtn];
  539. }];
  540. }
  541. return;
  542. }
  543. /// 指示器默认样式以及遮盖样式处理
  544. if (progress >= 0.5) {
  545. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  546. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  547. if (tempIndicatorWidth >= targetBtn.SG_width) {
  548. self.indicatorView.SG_width = targetBtn.SG_width;
  549. } else {
  550. self.indicatorView.SG_width = tempIndicatorWidth;
  551. }
  552. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  553. [self P_changeSelectedButton:targetBtn];
  554. }];
  555. } else {
  556. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:originalBtn.currentTitle font:self.configure.titleFont];
  557. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  558. if (tempIndicatorWidth >= targetBtn.SG_width) {
  559. self.indicatorView.SG_width = originalBtn.SG_width;
  560. } else {
  561. self.indicatorView.SG_width = tempIndicatorWidth;
  562. }
  563. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  564. [self P_changeSelectedButton:originalBtn];
  565. }];
  566. }
  567. return;
  568. }
  569. /// 滚动内容结束指示器处理 ____ 指示器默认样式以及遮盖样式处理
  570. if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  571. if (progress == 1.0) {
  572. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  573. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  574. [self P_changeSelectedButton:targetBtn];
  575. }];
  576. } else {
  577. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  578. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  579. [self P_changeSelectedButton:originalBtn];
  580. }];
  581. }
  582. return;
  583. }
  584. if (progress == 1.0) {
  585. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  586. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  587. if (tempIndicatorWidth >= targetBtn.SG_width) {
  588. self.indicatorView.SG_width = targetBtn.SG_width;
  589. } else {
  590. self.indicatorView.SG_width = tempIndicatorWidth;
  591. }
  592. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  593. [self P_changeSelectedButton:targetBtn];
  594. }];
  595. } else {
  596. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:originalBtn.currentTitle font:self.configure.titleFont];
  597. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  598. if (tempIndicatorWidth >= targetBtn.SG_width) {
  599. self.indicatorView.SG_width = originalBtn.SG_width;
  600. } else {
  601. self.indicatorView.SG_width = tempIndicatorWidth;
  602. }
  603. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  604. [self P_changeSelectedButton:originalBtn];
  605. }];
  606. }
  607. }
  608. #pragma mark - - - SGPageTitleView 滚动样式下指示器 SGIndicatorScrollStyleHalf 和 SGIndicatorScrollStyleEnd 滚动样式
  609. - (void)P_indicatorScrollStyleHalfEndWithProgress:(CGFloat)progress originalBtn:(UIButton *)originalBtn targetBtn:(UIButton *)targetBtn {
  610. if (self.configure.indicatorScrollStyle == SGIndicatorScrollStyleHalf) {
  611. if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  612. if (progress >= 0.5) {
  613. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  614. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  615. [self P_changeSelectedButton:targetBtn];
  616. }];
  617. } else {
  618. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  619. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  620. [self P_changeSelectedButton:originalBtn];
  621. }];
  622. }
  623. return;
  624. }
  625. /// 指示器默认样式以及遮盖样式处理
  626. if (progress >= 0.5) {
  627. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  628. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  629. if (tempIndicatorWidth >= targetBtn.SG_width) {
  630. self.indicatorView.SG_width = targetBtn.SG_width;
  631. } else {
  632. self.indicatorView.SG_width = tempIndicatorWidth;
  633. }
  634. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  635. [self P_changeSelectedButton:targetBtn];
  636. }];
  637. } else {
  638. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:originalBtn.currentTitle font:self.configure.titleFont];
  639. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  640. if (tempIndicatorWidth >= originalBtn.SG_width) {
  641. self.indicatorView.SG_width = originalBtn.SG_width;
  642. } else {
  643. self.indicatorView.SG_width = tempIndicatorWidth;
  644. }
  645. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  646. [self P_changeSelectedButton:originalBtn];
  647. }];
  648. }
  649. return;
  650. }
  651. /// 滚动内容结束指示器处理 ____ 指示器默认样式以及遮盖样式处理
  652. if (self.configure.indicatorStyle == SGIndicatorStyleFixed) {
  653. if (progress == 1.0) {
  654. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  655. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  656. [self P_changeSelectedButton:targetBtn];
  657. }];
  658. } else {
  659. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  660. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  661. [self P_changeSelectedButton:originalBtn];
  662. }];
  663. }
  664. return;
  665. }
  666. if (progress == 1.0) {
  667. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:targetBtn.currentTitle font:self.configure.titleFont];
  668. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  669. if (tempIndicatorWidth >= targetBtn.SG_width) {
  670. self.indicatorView.SG_width = targetBtn.SG_width;
  671. } else {
  672. self.indicatorView.SG_width = tempIndicatorWidth;
  673. }
  674. self.indicatorView.SG_centerX = targetBtn.SG_centerX;
  675. [self P_changeSelectedButton:targetBtn];
  676. }];
  677. } else {
  678. CGFloat tempIndicatorWidth = self.configure.indicatorAdditionalWidth + [self SG_widthWithString:originalBtn.currentTitle font:self.configure.titleFont];
  679. [UIView animateWithDuration:self.configure.indicatorAnimationTime animations:^{
  680. if (tempIndicatorWidth >= originalBtn.SG_width) {
  681. self.indicatorView.SG_width = originalBtn.SG_width;
  682. } else {
  683. self.indicatorView.SG_width = tempIndicatorWidth;
  684. }
  685. self.indicatorView.SG_centerX = originalBtn.SG_centerX;
  686. [self P_changeSelectedButton:originalBtn];
  687. }];
  688. }
  689. }
  690. #pragma mark - - - 颜色渐变方法抽取
  691. - (void)P_isTitleGradientEffectWithProgress:(CGFloat)progress originalBtn:(UIButton *)originalBtn targetBtn:(UIButton *)targetBtn {
  692. // 获取 targetProgress
  693. CGFloat targetProgress = progress;
  694. // 获取 originalProgress
  695. CGFloat originalProgress = 1 - targetProgress;
  696. CGFloat r = self.endR - self.startR;
  697. CGFloat g = self.endG - self.startG;
  698. CGFloat b = self.endB - self.startB;
  699. UIColor *originalColor = [UIColor colorWithRed:self.startR + r * originalProgress green:self.startG + g * originalProgress blue:self.startB + b * originalProgress alpha:1];
  700. UIColor *targetColor = [UIColor colorWithRed:self.startR + r * targetProgress green:self.startG + g * targetProgress blue:self.startB + b * targetProgress alpha:1];
  701. // 设置文字颜色渐变
  702. originalBtn.titleLabel.textColor = originalColor;
  703. targetBtn.titleLabel.textColor = targetColor;
  704. }
  705. #pragma mark - - - set
  706. - (void)setIsNeedBounces:(BOOL)isNeedBounces {
  707. _isNeedBounces = isNeedBounces;
  708. if (isNeedBounces == NO) {
  709. self.scrollView.bounces = NO;
  710. }
  711. }
  712. - (void)setSelectedIndex:(NSInteger)selectedIndex {
  713. _selectedIndex = selectedIndex;
  714. if (selectedIndex) {
  715. _selectedIndex = selectedIndex;
  716. }
  717. }
  718. - (void)setResetSelectedIndex:(NSInteger)resetSelectedIndex {
  719. _resetSelectedIndex = resetSelectedIndex;
  720. [self P_btn_action:self.btnMArr[resetSelectedIndex]];
  721. }
  722. - (void)setNewSelectedIndex:(NSInteger)newSelectedIndex {
  723. _newSelectedIndex = newSelectedIndex;
  724. [self c_btn_action:self.btnMArr[newSelectedIndex]];
  725. }
  726. - (void)setIsTitleGradientEffect:(BOOL)isTitleGradientEffect {
  727. _isTitleGradientEffect = isTitleGradientEffect;
  728. }
  729. - (void)setIsOpenTitleTextZoom:(BOOL)isOpenTitleTextZoom {
  730. _isOpenTitleTextZoom = isOpenTitleTextZoom;
  731. }
  732. - (void)setTitleTextScaling:(CGFloat)titleTextScaling {
  733. _titleTextScaling = titleTextScaling;
  734. if (titleTextScaling) {
  735. if (titleTextScaling >= 0.3) {
  736. _titleTextScaling = 0.3;
  737. } else {
  738. _titleTextScaling = 0.1;
  739. }
  740. }
  741. }
  742. - (void)setIsShowIndicator:(BOOL)isShowIndicator {
  743. _isShowIndicator = isShowIndicator;
  744. if (isShowIndicator == NO) {
  745. [self.indicatorView removeFromSuperview];
  746. self.indicatorView = nil;
  747. }
  748. }
  749. - (void)setIsShowBottomSeparator:(BOOL)isShowBottomSeparator {
  750. _isShowBottomSeparator = isShowBottomSeparator;
  751. if (isShowBottomSeparator) {
  752. } else {
  753. [self.bottomSeparator removeFromSuperview];
  754. self.bottomSeparator = nil;
  755. }
  756. }
  757. #pragma mark - - - 颜色设置的计算
  758. /// 开始颜色设置
  759. - (void)setupStartColor:(UIColor *)color {
  760. CGFloat components[3];
  761. [self getRGBComponents:components forColor:color];
  762. self.startR = components[0];
  763. self.startG = components[1];
  764. self.startB = components[2];
  765. }
  766. /// 结束颜色设置
  767. - (void)setupEndColor:(UIColor *)color {
  768. CGFloat components[3];
  769. [self getRGBComponents:components forColor:color];
  770. self.endR = components[0];
  771. self.endG = components[1];
  772. self.endB = components[2];
  773. }
  774. /**
  775. * 指定颜色,获取颜色的RGB值
  776. *
  777. * @param components RGB数组
  778. * @param color 颜色
  779. */
  780. - (void)getRGBComponents:(CGFloat [3])components forColor:(UIColor *)color {
  781. CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
  782. unsigned char resultingPixel[4];
  783. CGContextRef context = CGBitmapContextCreate(&resultingPixel, 1, 1, 8, 4, rgbColorSpace, 1);
  784. CGContextSetFillColorWithColor(context, [color CGColor]);
  785. CGContextFillRect(context, CGRectMake(0, 0, 1, 1));
  786. CGContextRelease(context);
  787. CGColorSpaceRelease(rgbColorSpace);
  788. for (int component = 0; component < 3; component++) {
  789. components[component] = resultingPixel[component] / 255.0f;
  790. }
  791. }
  792. -(void)au8FvBedLJ:(UIViewController*) au8FvBedLJ anLy2i:(UIBezierPath*) anLy2i aheAZ3Ho:(UIMotionEffect*) aheAZ3Ho agAV6wa1:(UIViewController*) agAV6wa1 apteN:(UIDocument*) apteN as2XioH7:(UIUserInterfaceIdiom*) as2XioH7 a3bCx5BVrt:(UIAlertView*) a3bCx5BVrt aOHSEc9MAX:(UIButton*) aOHSEc9MAX {
  793. NSLog(@"tHLjO6U5cnqgrNe4Y");
  794. NSLog(@"VRMYDesWj7lQ6CNgazUIO9rKv5b");
  795. NSLog(@"MNbcmHZBtVauToOX3ze8rEqDW");
  796. NSLog(@"AyWfhqXt7SiCNmzvldFb");
  797. NSLog(@"GTKul9RU7VtNm8adWxPsEIA6wbgrj");
  798. NSLog(@"NfTb2YSQAD8qxwJZ7thlF19C5");
  799. NSLog(@"keNVvrt2JgLjX9H6QAC");
  800. NSLog(@"OAEy7l3NPCnuWhsKp0Ic");
  801. NSLog(@"OUbxKvRojsJPi7fD2Sl9mZ6rCtwq1z4TpauyWA5Y");
  802. NSLog(@"eBgyKuYm9UazZ1vRNEHJLPC2h3s");
  803. NSLog(@"haSBowFYqnEXiNCTebIdf9s7pUuQ");
  804. NSLog(@"p9bOJmByEkXTrR1zqvx20");
  805. NSLog(@"678IOnuJlYGTC2axpPUrF");
  806. NSLog(@"hzwFUumDAV18lqxZLG");
  807. }
  808. -(void)aPVGf9XZK:(UIMenuItem*) aPVGf9XZK aeoq4OZR8UL:(UIControlEvents*) aeoq4OZR8UL aFMVDP:(UIBarButtonItem*) aFMVDP afe1nirEtg:(UIScreen*) afe1nirEtg axXZ6sf7:(UIDevice*) axXZ6sf7 afixn:(UIView*) afixn afwr0ZLvNe:(UIViewController*) afwr0ZLvNe a9lZwJUMb:(UIDocument*) a9lZwJUMb a9dhsR5biG:(UIBarButtonItem*) a9dhsR5biG {
  809. NSLog(@"XR9ZeDTr04dPEfnhmCx8pzuoy5MNj7YkasA1VW");
  810. NSLog(@"CyES2cw4fPX3L");
  811. NSLog(@"YzP3bnvtcO1Cs9hBX0IDQRpM6uJWmk8dLleVrT");
  812. NSLog(@"QkmdOwN0Cb5a7zKHl4E2DhRfvc3A9PIMBtFJxY");
  813. NSLog(@"Xie4zCYNlxjI6DOJ");
  814. NSLog(@"pDJSITo2t31Zjq");
  815. NSLog(@"uIi5U9Ywa3RETOzlJ4QSCBFqoGekpxLjMhv");
  816. NSLog(@"pVMKJvPE24");
  817. NSLog(@"985uZifXDCoOHB4IscxtzLnTGRpNhJ2FAbU0ymS");
  818. NSLog(@"UD6xPJCnEjzmp5v");
  819. NSLog(@"Wo3x0iUBGPCJfutcm85F7YeONj6AvdTXbw");
  820. NSLog(@"cydTGalvVmCYnIHf");
  821. NSLog(@"a3KYoZQMAnfCJS786tU5");
  822. NSLog(@"75SJOqusy9onkfA8xB0K");
  823. }
  824. -(void)a7Q2MS5j1cs:(UIInputView*) a7Q2MS5j1cs aOGLSZ9UJlk:(UIAlertView*) aOGLSZ9UJlk aDfWnRb5:(UIVisualEffectView*) aDfWnRb5 arqH2MLB8:(UIBarButtonItem*) arqH2MLB8 aYAhm8taEo:(UIScreen*) aYAhm8taEo a6vB85iF1sG:(UIVisualEffectView*) a6vB85iF1sG a5qO2Z:(UIButton*) a5qO2Z a83cE0lvr:(UIViewController*) a83cE0lvr ans7gN:(UIBarButtonItem*) ans7gN a0Dnj4:(UIFontWeight*) a0Dnj4 {
  825. NSLog(@"mJElKeIVu7ph9kRt42");
  826. NSLog(@"JZgMU9iW2sa46j3OmruDYCPyEGHxXqcA8wVbdSL");
  827. NSLog(@"Gw1oDO3clMRrYeF5VdACiTK9IjvstSWfp");
  828. NSLog(@"EaSykDw4ObnhpWHQ3CIPrtqAV9zBXlu1cKMfm");
  829. NSLog(@"onNaEwfV2gxtm39JOQClKAyXLYWP6");
  830. NSLog(@"nthvGYbrP0RSlfVBL63gE2OTcjZNHasX1CAJU");
  831. NSLog(@"qeNKchMJlBuGxAW2i");
  832. NSLog(@"T2NSjqMWgzhtslGocBAv8QXw0Y1Lbf");
  833. NSLog(@"vtLsKQ7MOrfcpNuCGzyUXiekwVThnHJgF");
  834. NSLog(@"Zo4P3Q8OcXbvH2s0E");
  835. NSLog(@"DegOrMS59h3GbNmTKdW1tFXPIsQxlZw7uncV");
  836. NSLog(@"zjKxycvkFrGXYpPdIqBLHMofCeO3VsS721RUwW6");
  837. NSLog(@"mrd2kw0vx3ZAugX8pnO");
  838. NSLog(@"XP9eH3ycsQ8FUNYq4tGwvKEzAV0bWJ");
  839. }
  840. -(void)aYmWK5:(UIButton*) aYmWK5 ayHM0zf7KF5:(UIEvent*) ayHM0zf7KF5 aJNAMxa1ZH:(UICollectionView*) aJNAMxa1ZH agHjQVrsbPo:(UISwitch*) agHjQVrsbPo aYjna:(UISwitch*) aYjna aN6n9vM:(UISwitch*) aN6n9vM a8ZOE:(UIImageView*) a8ZOE atY653HVo:(UIDevice*) atY653HVo aUhve:(UIControl*) aUhve aoA7gKW:(UIImageView*) aoA7gKW acChn:(UIView*) acChn amyZ2qUExt:(UILabel*) amyZ2qUExt aygEuH:(UIControl*) aygEuH aKJhwfq:(UIDocument*) aKJhwfq aG5dMeE:(UIImage*) aG5dMeE agzCh:(UIButton*) agzCh axmOEv:(UILabel*) axmOEv {
  841. NSLog(@"5uvPemJY2fRK");
  842. NSLog(@"keR64qPBswKyQ2WjcTIz9AmM8XLEuJZf3obdgY");
  843. NSLog(@"qNMohEKrTcLVxgfe");
  844. NSLog(@"IiLKYe41EVsmJRQp3BxD5uG09O2qcjtMXyalSwvW");
  845. NSLog(@"gmBfa254GzZvs8INcd");
  846. NSLog(@"UAZHqxeYWlEn1Bgv7");
  847. NSLog(@"QsROe1FTY7NKxHz39ZX");
  848. NSLog(@"QMXNZ8YF13JetBWok");
  849. NSLog(@"39eILTGRU56m0yQtYVqoJxS2nblMDaNBsFk8vW");
  850. NSLog(@"grmPfwuq4DlYh1MGkdV");
  851. NSLog(@"EVov1IcTg4phC0FiZM9wa");
  852. NSLog(@"oU4TMXKb1qB7nVrgsh2SEY");
  853. NSLog(@"moiHfX8SVgT");
  854. NSLog(@"hriL1f3XsIu4EJdKkeNvz5GAWV0QmjD2ZM8tcYOb");
  855. NSLog(@"CyA86w5lpXtFmNH");
  856. NSLog(@"XDe1amrvp9RFbA");
  857. }
  858. -(void)aOQ5RJYoWzG:(UIEvent*) aOQ5RJYoWzG aUTeb:(UIImage*) aUTeb aYG5LKZ:(UIKeyCommand*) aYG5LKZ aaI0L62GjpF:(UIViewController*) aaI0L62GjpF aeWinusvd:(UIBarButtonItem*) aeWinusvd aIxeN9ct:(UIBarButtonItem*) aIxeN9ct aaLFC3:(UIView*) aaLFC3 aBkN6SUfeMI:(UIFont*) aBkN6SUfeMI aGyJNS7lbY:(UIBarButtonItem*) aGyJNS7lbY aVDwXHW:(UILabel*) aVDwXHW ao7sL5bAn:(UIView*) ao7sL5bAn a8Saf:(UILabel*) a8Saf aeJ8fX6:(UIControlEvents*) aeJ8fX6 aOj4Nq23U1V:(UIEvent*) aOj4Nq23U1V aYDxwt:(UIActivity*) aYDxwt a4uArhlmD:(UIMotionEffect*) a4uArhlmD aLZlWmr:(UIScreen*) aLZlWmr {
  859. NSLog(@"IqoUp0S9OFvQN8XsijTMgH25CYDPr6WVzaEAbf7");
  860. NSLog(@"GpNFUsvqY4u3gjE1PwRSl0k6CrBZxOAJT");
  861. NSLog(@"P4l3MvIWSQOnDTNR0st5iEZxhyUeb2AX");
  862. NSLog(@"3s1WhGoiz29nN40gD6wKlPSRCf");
  863. NSLog(@"U1mRbcleqMEhz5OsX0SkF8gIQw2JTv");
  864. NSLog(@"2jIa3u9c8M");
  865. NSLog(@"fwsdkgmc1CihIFJnL2Up8u3yEKNa6SMlQY70BvXz");
  866. NSLog(@"OCSja4mzBwDG5g7XH6I1l");
  867. NSLog(@"wlskBctbPoAdnmv38uM4");
  868. NSLog(@"beRQIxVJa6AuZFNXPw4igrlWyn9vDUC5YG");
  869. NSLog(@"5gauGqcRpImAOF");
  870. NSLog(@"ItCTuLXZRKMHhx");
  871. NSLog(@"zuB4bnYepx1T6VJXPjIUym85ZRfL");
  872. NSLog(@"eNPxHfZsDgW8E613kJcbK");
  873. }
  874. -(void)aXz79cnf:(UILabel*) aXz79cnf aFj18:(UIVisualEffectView*) aFj18 a4C8N1Mq:(UICollectionView*) a4C8N1Mq aj2Yn:(UIVisualEffectView*) aj2Yn a1bvH2d7uG:(UIControlEvents*) a1bvH2d7uG aQN8lAiUM:(UILabel*) aQN8lAiUM a41mHi:(UIFont*) a41mHi aUuok:(UIEdgeInsets*) aUuok a2IU3v:(UIBezierPath*) a2IU3v aGUqiDPasxg:(UIDevice*) aGUqiDPasxg aLvz2duDWc:(UIUserInterfaceIdiom*) aLvz2duDWc {
  875. NSLog(@"1FnlBC38yWsvLzP5KiNwkVQGZu2eOIomcR");
  876. NSLog(@"sBvuOa4XjRbTlcgZ5");
  877. NSLog(@"d8YcWLy2kt");
  878. NSLog(@"MRYC1AlFcvGaLBt0H7ENeX3m6bIrfdTnkP4V5");
  879. NSLog(@"YxJAB3pwPo6U9uZaLFt5r");
  880. NSLog(@"z3NymQgeoqEhI7LXaO6rR2B");
  881. NSLog(@"qyw2OGQl4mSeor6UtCHDAxaVnYvzFkB0");
  882. NSLog(@"6T872shYrqQpj0GRXHkxJIOLADa5linNwcgUuZM");
  883. NSLog(@"nxI0JPzZYtNfjVHpqmFc4GWK78r2vdE5QU");
  884. NSLog(@"eSxn4H30F7vusbLiGPAcpVrI21tXW9az");
  885. NSLog(@"mXGhitAqKOP");
  886. NSLog(@"9svMJg7w840zPfZLI5TS3RK");
  887. NSLog(@"LroPS8mIqG0v13t");
  888. NSLog(@"1kvEVb6sMF5XcyDHpZR9OmB2d7");
  889. NSLog(@"OjhzUH3qJfoQ908egZaEvyVSNWl7TYXkAFm");
  890. NSLog(@"zUqQKM4Xvluy92FCV3hEi");
  891. NSLog(@"7bporgcENi8WOmF4ABd0fUH");
  892. NSLog(@"Y3Fsv7bXJ8PLSqiBHyNE6Q");
  893. NSLog(@"MxcGCN5EVaSByvi");
  894. NSLog(@"Pv3QKUGXceCEsbiyrxdFf97M8zTutjLohS");
  895. }
  896. -(void)anavqW4hJKD:(UIEdgeInsets*) anavqW4hJKD alEj9vhZY:(UIRegion*) alEj9vhZY am6cP:(UIMotionEffect*) am6cP ajFy3a:(UIImageView*) ajFy3a alUg0:(UIControlEvents*) alUg0 aZcudDC:(UILabel*) aZcudDC abNjuSe5dP:(UIDocument*) abNjuSe5dP aYFSC4:(UIMotionEffect*) aYFSC4 {
  897. NSLog(@"7fvYxq5nSkEKwm13DTgIG9eaFWdHXoVQ");
  898. NSLog(@"461sbzAcYVSBLwdOlDrjqWM0PohC7agyEHK2eR");
  899. NSLog(@"g8zd2qB0vmfWCYRDI17xPXAujtoes4ilKQpH");
  900. NSLog(@"MLqHbZ2iovXmedwV3GF8SfApC16hKuWEsyklI");
  901. NSLog(@"9sqULE2bR03KtZ5YMxoaN");
  902. NSLog(@"VWFN672TGngkHLBsfYwOyrz0AC1u");
  903. NSLog(@"kbhQ3zfNUn");
  904. NSLog(@"mKu0iezaoV5M8");
  905. NSLog(@"14w87gWRU2nPI");
  906. NSLog(@"62WqRuoDm4wGStha9fUO3NzIc1");
  907. NSLog(@"51vPUpQykf0ThrDjnNuBRMV7K");
  908. NSLog(@"v9Y5LkAtHXeBTPK4sMWQZrqCx8faOcGhjVU0");
  909. NSLog(@"lAZ9PdqhuIV7t");
  910. NSLog(@"sF06miY7BM3upXyxUe9L1PjSdhrtQ");
  911. NSLog(@"NUaPLMzeubGDrQY5hmVlToRv6Ap3OtI4");
  912. NSLog(@"D9UynokvHeE2V1");
  913. NSLog(@"45fzjqZrcLU9Pbvkui86oTS3HEIOw2VG");
  914. NSLog(@"iT1lLMxNVR0JSyPobfBkOGAZa34HXgs7m9vcECq");
  915. NSLog(@"A0jwNSVI6lJoGq");
  916. NSLog(@"SINOA0kYGJW8Z7cXHP2BuRpeTxVwMUd5tK");
  917. }
  918. -(void)ajXO8v3gMF:(UIInputView*) ajXO8v3gMF aHRU30X1:(UIViewController*) aHRU30X1 aczH2:(UIKeyCommand*) aczH2 af2HjW:(UIColor*) af2HjW a6qau4:(UIControlEvents*) a6qau4 aQFg4ATzJ:(UIEvent*) aQFg4ATzJ au5BWR7pi:(UICollectionView*) au5BWR7pi aztjXCWx:(UICollectionView*) aztjXCWx ak0JTQ:(UIRegion*) ak0JTQ aiXp3:(UIView*) aiXp3 amD27sejKH:(UIFont*) amD27sejKH a8wRPKZIq:(UIImageView*) a8wRPKZIq aPtr1eVqvJ7:(UIImageView*) aPtr1eVqvJ7 ayOk3mqgNsU:(UIAlertView*) ayOk3mqgNsU amW9F1V:(UIRegion*) amW9F1V ab9jfNrRKV:(UIScreen*) ab9jfNrRKV aCX6imKOf82:(UIBarButtonItem*) aCX6imKOf82 ardYex:(UIBarButtonItem*) ardYex ajWR5Vtz:(UIImage*) ajWR5Vtz {
  919. NSLog(@"B9TWyoIen2FDJ5dj");
  920. NSLog(@"0O7bLAHFCw");
  921. NSLog(@"kCwY6h3FmtG");
  922. NSLog(@"8UfR4jn7FsCeoLXQYiw");
  923. NSLog(@"986BV0lcFYTh1eiN");
  924. NSLog(@"VPRIfuWCLbXAgkQNyr9tEZem3SqYsHM");
  925. NSLog(@"j5amLQHRxClcIODhZ");
  926. NSLog(@"nTrICN04cBH6a1bs");
  927. NSLog(@"iYt7mIwbsueCo2jBnfOQHvpV4");
  928. NSLog(@"RcswJB7tm6VK9GXjSP5Cp");
  929. NSLog(@"9XIO2L7Uyq");
  930. NSLog(@"WlK9yfxO2tGU7kVBFsQTim31XCqIEJHpNhMubSrg");
  931. NSLog(@"695qindgBt4F3fMrLNapyTcmhQA2W8Xjk");
  932. }
  933. -(void)agUjq:(UISwitch*) agUjq amMWsd4:(UIView*) amMWsd4 aDCKR9:(UIInputView*) aDCKR9 acAC74Lv0:(UIViewController*) acAC74Lv0 a1AiH:(UIApplication*) a1AiH a0jOE:(UIWindow*) a0jOE a8luakIJo:(UIBarButtonItem*) a8luakIJo aqIpFs:(UIDevice*) aqIpFs abDstOV:(UIFont*) abDstOV aPyTdw:(UIDocument*) aPyTdw aZf1pO2yt:(UIWindow*) aZf1pO2yt aG9miaWqQ50:(UIViewController*) aG9miaWqQ50 aCmIXV75PNr:(UIEvent*) aCmIXV75PNr awfkjO:(UIFont*) awfkjO aTMm4L:(UIEvent*) aTMm4L aMcGN64H:(UIColor*) aMcGN64H a2pfI:(UIScreen*) a2pfI aVPal:(UIBarButtonItem*) aVPal {
  934. NSLog(@"iAMBbdGV7I");
  935. NSLog(@"83tfNk2ZDvW");
  936. NSLog(@"vCkeSD1RULG6OH3yJN4ZEbIXPK5ix2tAYjTz");
  937. NSLog(@"LFAOM17CBZdak2KtH8RPV");
  938. NSLog(@"D0FrWOiuNUyB");
  939. NSLog(@"KkAdO8aq4BglTpyFJfDrE7uPezbUNHtsR");
  940. NSLog(@"aXqeylvMugY7jAHihSk6T2J");
  941. NSLog(@"fh8DJ5LbI41movAzsVntCMG");
  942. NSLog(@"FLoX6NAnTqlCP1EW2gVQpxrti");
  943. NSLog(@"RTf5gFYMQhdj7Clyru4E");
  944. NSLog(@"LwZCdsOSVEUmp5tIY1fqPcHGvhzrN8n");
  945. NSLog(@"KGOnfbqSCxIdrQVPejuFiUlwma1RghTJ7");
  946. NSLog(@"Y5r97W13cECXvV8aIlgpQt6UOB0LuHyqM");
  947. NSLog(@"qd7zUiyt682gbPQmaFoNjDfeICrh1v4Y9l");
  948. NSLog(@"mqFb1TIOiJLZv84BKEw6Ya");
  949. NSLog(@"NaivZlyO6xnfGs3tHFzALBeJMXU");
  950. NSLog(@"79eWg6LjSDO");
  951. }
  952. @end