Skip to content

Commit

Permalink
[Releases 1.6.7]
Browse files Browse the repository at this point in the history
  • Loading branch information
哥哥帅 committed Jul 27, 2019
1 parent f1f4f00 commit f929940
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 20 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ SGPageContentCollectionView(内部由 UICollectionView 实现)

* `指示器长度自定义`<br>

* `多种指示器滚动样式`<br>

* `标题文字渐显效果`<br>

* `标题文字缩放效果`<br>

* `多种指示器滚动样式`<br>
* `标题文字富文本样式`<br>


## Installation
* 1、CocoaPods 导入 pod 'SGPagingView', '~> 1.6.6'
* 1、CocoaPods 导入 pod 'SGPagingView', '~> 1.6.7'
* 2、下载、拖拽 “SGPagingView” 文件夹到工程中


Expand Down Expand Up @@ -180,6 +182,8 @@ b. 实现 SGPageContentScrollView 的 pageContentScrollView:index:代理方法

* 2019-07-22 :v1.6.6 SGPageTitleViewConfigure 新增 equivalence 属性支持静止样式下标题从左到右自动布局

* 2019-07-27 :v1.6.7 支持标题文字上下行样式以及 titleGradientEffect 属性与 resetTitleColor:titleSelectedColor: 方法的兼容


## License
SGPagingView is released under the MIT license. See [LICENSE](https://github.com/kingsic/SGPagingView/blob/master/LICENSE) for details.
2 changes: 1 addition & 1 deletion SGPagingView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SGPagingView'
s.version = '1.6.6'
s.version = '1.6.7'
s.summary = 'A powerful and easy to use segment control'
s.homepage = 'https://github.com/kingsic/SGPagingView'
s.license = 'MIT'
Expand Down
21 changes: 15 additions & 6 deletions SGPagingView/SGPageTitle/SGPageTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ - (void)setupTitleButtons {
SGPageTitleButton *btn = [[SGPageTitleButton alloc] init];
btn.tag = index;
btn.titleLabel.font = self.configure.titleFont;
btn.titleLabel.textAlignment = NSTextAlignmentCenter;
btn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[btn setTitle:self.titleArr[index] forState:(UIControlStateNormal)];
[btn setTitleColor:self.configure.titleColor forState:(UIControlStateNormal)];
[btn setTitleColor:self.configure.titleSelectedColor forState:(UIControlStateSelected)];
Expand Down Expand Up @@ -365,7 +367,7 @@ - (void)P_changeSelectedButton:(UIButton *)button {
UIFont *defaultTitleFont = [UIFont systemFontOfSize:15];
if ([configureTitleSelectedFont.fontName isEqualToString:defaultTitleFont.fontName] && configureTitleSelectedFont.pointSize == defaultTitleFont.pointSize) {
// 标题文字缩放属性(开启 titleSelectedFont 属性将不起作用)
if (self.configure.titleTextZoom == YES) {
if (self.configure.titleTextZoom) {
[self.btnMArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIButton *btn = obj;
btn.transform = CGAffineTransformIdentity;
Expand Down Expand Up @@ -397,7 +399,7 @@ - (void)P_changeSelectedButton:(UIButton *)button {
}

// 此处作用:避免滚动过程中点击标题手指不离开屏幕的前提下再次滚动造成的误差(由于文字渐变效果导致未选中标题的不准确处理)
if (self.configure.titleGradientEffect == YES) {
if (self.configure.titleGradientEffect) {
[self.btnMArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIButton *btn = obj;
btn.titleLabel.textColor = self.configure.titleColor;
Expand All @@ -406,7 +408,7 @@ - (void)P_changeSelectedButton:(UIButton *)button {
}
} else {
// 此处作用:避免滚动过程中点击标题手指不离开屏幕的前提下再次滚动造成的误差(由于文字渐变效果导致未选中标题的不准确处理)
if (self.configure.titleGradientEffect == YES) {
if (self.configure.titleGradientEffect) {
[self.btnMArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIButton *btn = obj;
btn.titleLabel.textColor = self.configure.titleColor;
Expand Down Expand Up @@ -502,15 +504,15 @@ - (void)setPageTitleViewWithProgress:(CGFloat)progress originalIndex:(NSInteger)
}
}
// 4、颜色的渐变(复杂)
if (self.configure.titleGradientEffect == YES) {
if (self.configure.titleGradientEffect) {
[self P_isTitleGradientEffectWithProgress:progress originalBtn:originalBtn targetBtn:targetBtn];
}

// 5 、标题文字缩放属性(开启文字选中字号属性将不起作用)
UIFont *configureTitleSelectedFont = self.configure.titleSelectedFont;
UIFont *defaultTitleFont = [UIFont systemFontOfSize:15];
if ([configureTitleSelectedFont.fontName isEqualToString:defaultTitleFont.fontName] && configureTitleSelectedFont.pointSize == defaultTitleFont.pointSize) {
if (self.configure.titleTextZoom == YES) {
if (self.configure.titleTextZoom) {
// originalBtn 缩放
CGFloat originalBtnZoomRatio = (1 - progress) * self.configure.titleTextZoomRatio;
originalBtn.transform = CGAffineTransformMakeScale(originalBtnZoomRatio + 1, originalBtnZoomRatio + 1);
Expand Down Expand Up @@ -593,6 +595,13 @@ - (void)resetTitleColor:(UIColor *)color titleSelectedColor:(UIColor *)selectedC
[btn setTitleColor:color forState:(UIControlStateNormal)];
[btn setTitleColor:selectedColor forState:(UIControlStateSelected)];
}];

if (self.configure.titleGradientEffect) {
self.configure.titleColor = color;
self.configure.titleSelectedColor = selectedColor;
[self setupStartColor:self.configure.titleColor];
[self setupEndColor:self.configure.titleSelectedColor];
}
}
/**
* 重置标题普通状态、选中状态下文字颜色及指示器颜色方法
Expand Down Expand Up @@ -782,7 +791,7 @@ - (void)P_staticIndicatorScrollStyleDefaultWithProgress:(CGFloat)progress origin
CGFloat originalBtnMaxX = 0.0;
/// 这里的缩放是标题按钮缩放,按钮的 frame 会发生变化,开启缩放性后,如果指示器还使用 CGRectGetMaxX 获取按钮的最大 X 值是会比之前的值大,这样会导致指示器的位置相对按钮位置不对应(存在一定的偏移);所以这里根据按钮下标计算原本的 CGRectGetMaxX 的值,缩放后的不去理会,这样指示器位置会与按钮位置保持一致。
/// 在缩放属性关闭情况下,下面的计算结果一样的,所以可以省略判断,直接采用第一种计算结果(这个只是做个记录对指示器位置与按钮保持一致的方法)
if (self.configure.titleTextZoom == YES) {
if (self.configure.titleTextZoom) {
targetBtnMaxX = (targetBtn.tag + 1) * btnWidth;
originalBtnMaxX = (originalBtn.tag + 1) * btnWidth;
} else {
Expand Down
2 changes: 1 addition & 1 deletion SGPagingView/SGPagingView.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SGPagingView.h
// Version 1.6.6
// Version 1.6.7
// GitHub:https://github.com/kingsic/SGPagingView
//
// Created by kingsic on 2016/10/6.
Expand Down
6 changes: 6 additions & 0 deletions SGPagingViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
8D5BB745213AC303000E929E /* ChildTempPopGestureVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D5BB744213AC303000E929E /* ChildTempPopGestureVC.m */; };
8D5BB749213AC570000E929E /* SGPagingViewPopGestureVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D5BB747213AC570000E929E /* SGPagingViewPopGestureVC.m */; };
8D5E68CF20F2FA140068044C /* DefaultAnimatedVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D5E68CE20F2FA140068044C /* DefaultAnimatedVC.m */; };
8D69372622EC1E0200F91864 /* DefaultTopBottomVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D69372522EC1E0200F91864 /* DefaultTopBottomVC.m */; };
8DA4304120BBE3D600C47917 /* SGPageContentCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA4303F20BBE3D500C47917 /* SGPageContentCollectionView.m */; };
8DA4304420BBEDEC00C47917 /* UIButton+SGPagingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA4304320BBEDEC00C47917 /* UIButton+SGPagingView.m */; };
8DA4304720BBEF3B00C47917 /* DefaultImageVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA4304620BBEF3B00C47917 /* DefaultImageVC.m */; };
Expand Down Expand Up @@ -168,6 +169,8 @@
8D5BB748213AC570000E929E /* SGPagingViewPopGestureVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGPagingViewPopGestureVC.h; sourceTree = "<group>"; };
8D5E68CD20F2FA140068044C /* DefaultAnimatedVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DefaultAnimatedVC.h; sourceTree = "<group>"; };
8D5E68CE20F2FA140068044C /* DefaultAnimatedVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DefaultAnimatedVC.m; sourceTree = "<group>"; };
8D69372422EC1E0200F91864 /* DefaultTopBottomVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DefaultTopBottomVC.h; sourceTree = "<group>"; };
8D69372522EC1E0200F91864 /* DefaultTopBottomVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DefaultTopBottomVC.m; sourceTree = "<group>"; };
8DA4303F20BBE3D500C47917 /* SGPageContentCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SGPageContentCollectionView.m; sourceTree = "<group>"; };
8DA4304020BBE3D600C47917 /* SGPageContentCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGPageContentCollectionView.h; sourceTree = "<group>"; };
8DA4304220BBEDEC00C47917 /* UIButton+SGPagingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIButton+SGPagingView.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -356,6 +359,8 @@
8DF628F620A94CBA00B7B85A /* DefaultSystemVC.m */,
8DA4304520BBEF3B00C47917 /* DefaultImageVC.h */,
8DA4304620BBEF3B00C47917 /* DefaultImageVC.m */,
8D69372422EC1E0200F91864 /* DefaultTopBottomVC.h */,
8D69372522EC1E0200F91864 /* DefaultTopBottomVC.m */,
8D0F8E211FD95DE300F30426 /* DefaultGradientEffectVC.h */,
8D0F8E221FD95DE300F30426 /* DefaultGradientEffectVC.m */,
8D0F8E2F1FD95DE300F30426 /* DefaultZoomVC.h */,
Expand Down Expand Up @@ -588,6 +593,7 @@
8D0F8E6E1FD95E2300F30426 /* ChildVCSeven.m in Sources */,
8D5BB745213AC303000E929E /* ChildTempPopGestureVC.m in Sources */,
8D0F8E371FD95DE300F30426 /* DefaultStaticVC.m in Sources */,
8D69372622EC1E0200F91864 /* DefaultTopBottomVC.m in Sources */,
182513D21F21CC340039F4A2 /* NavigationBarVC.m in Sources */,
8DCB02AA1F95B0FF00C9598A /* SGPageTitleViewConfigure.m in Sources */,
8D0F8E3A1FD95DE300F30426 /* DefaultZoomVC.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions SGPagingViewExample/MainVC/DefaultTopBottomVC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// DefaultTopBottomVC.h
// SGPagingViewExample
//
// Created by kingsic on 2019/7/27.
// Copyright © 2019年 Sorgle. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface DefaultTopBottomVC : UIViewController

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit f929940

Please sign in to comment.