Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jht committed Sep 12, 2019
1 parent 6130ab1 commit 009b072
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 96 deletions.
2 changes: 1 addition & 1 deletion JhtBannerScrollView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'JhtBannerScrollView'
s.version = '1.0.4'
s.version = '1.0.5'
s.summary = 'banner/广告页/循环滚动广告图片/无限循环自动滚动卡片'
s.homepage = 'https://github.com/jinht/BannerScrollView'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
7 changes: 4 additions & 3 deletions JhtBannerScrollView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
TargetAttributes = {
8EFE0CB31EE0FFA8001F611A = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 8C4D9692Z4;
DevelopmentTeam = Q67TW3T8PL;
ProvisioningStyle = Automatic;
};
8EFE0CCC1EE0FFA8001F611A = {
Expand All @@ -376,6 +376,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -599,7 +600,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 8C4D9692Z4;
DEVELOPMENT_TEAM = Q67TW3T8PL;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand All @@ -618,7 +619,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 8C4D9692Z4;
DEVELOPMENT_TEAM = Q67TW3T8PL;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"idiom" : "iphone",
"filename" : "ios-template-180.png",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
21 changes: 21 additions & 0 deletions JhtBannerScrollView/Assets.xcassets/image_1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image_1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions JhtBannerScrollView/Assets.xcassets/image_2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image_2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions JhtBannerScrollView/Assets.xcassets/image_3.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image_3.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions JhtBannerScrollView/Assets.xcassets/image_4.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image_4.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions JhtBannerScrollView/Assets.xcassets/image_5.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "image_5.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions JhtBannerScrollView/JhtBannerView/JhtBannerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

#pragma mark - property
#pragma mark required
/** 图片数组 */
@property (nonatomic, strong) NSArray *imageArray;

/** 图片数组
* tips: [imageStr containsString:@"http"] ? 网络图片 : 本地图片(不会使用placeholderImageName作为占位图)
*/
@property (nonatomic, strong) NSArray<NSString *> *imageArray;

#pragma mark optional
/** 占位图片名(本地) */
@property (nonatomic, strong) NSString *placeholderImageName;



#pragma mark - Public Method
/** 点击内部卡片View回调的Block
* index在内容数组里的索引
/** 点击内部卡片View回调
* index: 在内容数组里的索引
*/
typedef void(^clickInsideCardView)(NSInteger index);
/** 点击ScrollView内部卡片 */
Expand Down
79 changes: 34 additions & 45 deletions JhtBannerScrollView/JhtBannerView/JhtBannerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//

#import "JhtBannerView.h"
#import <JhtBannerScrollView/JhtBannerScrollView.h>
#import "UIImageView+WebCache.h"
#import <JhtBannerScrollView/JhtBannerScrollView.h>

/** 单个卡片宽度 */
#define KBavCardViewWidth (480 / 2.0 * WidthScale375)
Expand All @@ -22,7 +22,6 @@ @interface JhtBannerView () <JhtBannerScrollViewDelegate, JhtBannerScrollViewDat
// 点击内部卡片View回调的Block
clickInsideCardView _block;
}

/** banner view(整条view) */
@property (nonatomic, strong) JhtBannerScrollView *bannerView;

Expand All @@ -38,47 +37,29 @@ - (instancetype)initWithFrame:(CGRect)frame {
if (self) {
self.backgroundColor = [UIColor greenColor];

// 添加相关控件
[self bavAddControl];
// 添加banner view(整条view)
[self addSubview:self.bannerView];
}

return self;
}

#pragma mark Init Method
/** 添加相关控件 */
- (void)bavAddControl {
// 添加banner view(整条view)
[self addSubview:self.bannerView];

// 自己扩展 pageControl
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.bannerView.frame) + 3, 100, 8)];
pageControl.center = CGPointMake(self.center.x, pageControl.center.y);
pageControl.numberOfPages = 4;
pageControl.pageIndicatorTintColor = [UIColor purpleColor];
self.bannerView.pageControl = pageControl;
[self addSubview:self.bannerView.pageControl];
}



#pragma mark - Public Method
/** 点击ScrollView内部卡片 */
- (void)clickScrollViewInsideCardView:(clickInsideCardView)clickBlock {
_block = clickBlock;
}



#pragma mark - Get
/** banner view(整条view) */
#pragma mark - Getter
- (JhtBannerScrollView *)bannerView {
if (!_bannerView) {
_bannerView = [[JhtBannerScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), KBavCardViewHeight)];

_bannerView.delegate = self;
_bannerView.dataSource = self;
_bannerView.minCoverViewAlpha = 0.2;
_bannerView.autoTime = 3.0;
_bannerView.minCoverViewAlpha = 0.2;
_bannerView.leftRightMargin = 25 / 2.0 * WidthScale375;
_bannerView.topBottomMargin = 15 / 2.0 * WidthScale375;
_bannerView.orientation = BV_Orientation_Horizontal;
Expand All @@ -89,14 +70,29 @@ - (JhtBannerScrollView *)bannerView {
}



#pragma mark - Set
/** 图片数组 */
- (void)setImageArray:(NSArray *)imageArray {
#pragma mark - Setter
- (void)setImageArray:(NSArray<NSString *> *)imageArray {
_imageArray = imageArray;

[_bannerView reloadData];

// 添加pageControl
[self bavAddPageControl];
}

#pragma mark Setter Method
/** 添加pageControl */
- (void)bavAddPageControl {
UIPageControl *pageC = [self viewWithTag:100];
[pageC removeFromSuperview];

UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.bannerView.frame) - 20 / 2.0 * WidthScale375, 100, 8)];
pageControl.tag = 100;
pageControl.center = CGPointMake(self.center.x, pageControl.center.y);
pageControl.numberOfPages = _imageArray.count;
self.bannerView.pageControl = pageControl;
[self addSubview:self.bannerView.pageControl];
}


#pragma mark - JhtBannerViewDelegate
Expand All @@ -111,8 +107,8 @@ - (void)bannerView:(JhtBannerScrollView *)bannerView didScrollToCardViewWithInde
}

/** 点击了第几个cardView
* bannerCardView点击cardView
* index点击bannerCardView的index
* bannerCardView: 点击cardView
* index: 点击bannerCardView的index
*/
- (void)bannerView:(JhtBannerScrollView *)bannerView didSelectCardView:(UIView *)cardView withCardViewIndex:(NSInteger)index {
if (_block) {
Expand All @@ -121,7 +117,6 @@ - (void)bannerView:(JhtBannerScrollView *)bannerView didSelectCardView:(UIView *
}



#pragma mark - JhtBannerViewDataSource
/** 显示cardView的个数 */
- (NSInteger)numberOfCardViewInBannerView:(JhtBannerScrollView *)bannerView {
Expand All @@ -135,22 +130,16 @@ - (UIView *)bannerView:(JhtBannerScrollView *)bannerView cardViewForBannerViewAt
cardView = [[JhtBannerCardView alloc] initWithFrame:CGRectMake(0, 0, KBavCardViewWidth, KBavCardViewHeight)];
cardView.tag = index;
}
// 加载网络图片
[cardView.cardImageView sd_setImageWithURL:[NSURL URLWithString:self.imageArray[index]] placeholderImage:[UIImage imageNamed:self.placeholderImageName]];

NSString *imageStr = self.imageArray[index];
if ([imageStr containsString:@"http"]) {
[cardView.cardImageView sd_setImageWithURL:[NSURL URLWithString:imageStr] placeholderImage:[UIImage imageNamed:self.placeholderImageName]];
} else {
cardView.cardImageView.image = [UIImage imageNamed:imageStr];
}

return cardView;
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/

@end
Loading

0 comments on commit 009b072

Please sign in to comment.