mirror of
https://github.com/wu736139669/ManagerDemo.git
synced 2026-10-06 18:40:10 +00:00
ADView
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
A94FE520199C9C6800626DE5 /* MoveSocialCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A94FE51F199C9C6800626DE5 /* MoveSocialCellView.xib */; };
|
||||
A96F2A7C199D008200608237 /* UIButton+Bootstrap.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A7B199D008200608237 /* UIButton+Bootstrap.m */; };
|
||||
A96F2A7F199D01C000608237 /* NSString+FontAwesome.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A7E199D01C000608237 /* NSString+FontAwesome.m */; };
|
||||
A96F2A85199D1D6800608237 /* HdPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A82199D1D6800608237 /* HdPageControl.m */; };
|
||||
A96F2A86199D1D6800608237 /* HDScrollview.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A84199D1D6800608237 /* HDScrollview.m */; };
|
||||
A988A8FC199A50D900EB10AA /* TriangleView.m in Sources */ = {isa = PBXBuildFile; fileRef = A988A8FB199A50D900EB10AA /* TriangleView.m */; };
|
||||
A988A900199A751500EB10AA /* FundListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A988A8FF199A751500EB10AA /* FundListCell.m */; };
|
||||
A988A902199A755300EB10AA /* FundListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A988A901199A755300EB10AA /* FundListCell.xib */; };
|
||||
@@ -156,6 +158,10 @@
|
||||
A96F2A7B199D008200608237 /* UIButton+Bootstrap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+Bootstrap.m"; sourceTree = "<group>"; };
|
||||
A96F2A7D199D01C000608237 /* NSString+FontAwesome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+FontAwesome.h"; sourceTree = "<group>"; };
|
||||
A96F2A7E199D01C000608237 /* NSString+FontAwesome.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+FontAwesome.m"; sourceTree = "<group>"; };
|
||||
A96F2A81199D1D6800608237 /* HdPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HdPageControl.h; sourceTree = "<group>"; };
|
||||
A96F2A82199D1D6800608237 /* HdPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HdPageControl.m; sourceTree = "<group>"; };
|
||||
A96F2A83199D1D6800608237 /* HDScrollview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDScrollview.h; sourceTree = "<group>"; };
|
||||
A96F2A84199D1D6800608237 /* HDScrollview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDScrollview.m; sourceTree = "<group>"; };
|
||||
A988A8FA199A50D900EB10AA /* TriangleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriangleView.h; sourceTree = "<group>"; };
|
||||
A988A8FB199A50D900EB10AA /* TriangleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TriangleView.m; sourceTree = "<group>"; };
|
||||
A988A8FE199A751500EB10AA /* FundListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FundListCell.h; sourceTree = "<group>"; };
|
||||
@@ -346,6 +352,17 @@
|
||||
path = UIButtonUtil;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A96F2A80199D1D6800608237 /* HDScrollView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A96F2A81199D1D6800608237 /* HdPageControl.h */,
|
||||
A96F2A82199D1D6800608237 /* HdPageControl.m */,
|
||||
A96F2A83199D1D6800608237 /* HDScrollview.h */,
|
||||
A96F2A84199D1D6800608237 /* HDScrollview.m */,
|
||||
);
|
||||
path = HDScrollView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A988A8F9199A50B600EB10AA /* UIViewShape */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -495,6 +512,7 @@
|
||||
A9AF6C4A19949B510076C0EE /* Common */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A96F2A80199D1D6800608237 /* HDScrollView */,
|
||||
A96F2A79199D007700608237 /* UIButtonUtil */,
|
||||
A988A8F9199A50B600EB10AA /* UIViewShape */,
|
||||
A93F87C71999E4DA00875287 /* AttributedString */,
|
||||
@@ -811,6 +829,8 @@
|
||||
files = (
|
||||
A93F8801199A077F00875287 /* ListViewController.m in Sources */,
|
||||
A988A8FC199A50D900EB10AA /* TriangleView.m in Sources */,
|
||||
A96F2A85199D1D6800608237 /* HdPageControl.m in Sources */,
|
||||
A96F2A86199D1D6800608237 /* HDScrollview.m in Sources */,
|
||||
A9EAA05619988C55001A872A /* MRCircularProgressView.m in Sources */,
|
||||
A9AF6C961994C5700076C0EE /* UIView+Extension.m in Sources */,
|
||||
A9AF6C921994C5700076C0EE /* MJRefreshFooterView.m in Sources */,
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// HdScrollView.h
|
||||
// ScrollView
|
||||
//
|
||||
// Created by Hu Di on 13-10-11.
|
||||
// Copyright (c) 2013年 Sanji. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "HdPageControl.h"
|
||||
@protocol HDScrollviewDelegate <NSObject>
|
||||
-(void)TapView:(int)index;
|
||||
@end
|
||||
|
||||
@interface HDScrollview : UIScrollView<UIScrollViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) NSTimer *autoScrollTimer;
|
||||
@property (nonatomic,strong) HdPageControl *pagecontrol;
|
||||
@property (nonatomic,assign) NSInteger currentPageIndex;
|
||||
@property (assign,nonatomic) id<HDScrollviewDelegate> HDdelegate;
|
||||
@property (nonatomic, assign) BOOL autoScroll; // default is YES, set NO to turn off autoScroll
|
||||
@property (nonatomic, assign) NSUInteger scrollInterval;
|
||||
/**
|
||||
* @brief 不循环
|
||||
*/
|
||||
-(id)initWithFrame:(CGRect)frame withImageView:(NSMutableArray *)imageview;
|
||||
|
||||
/**
|
||||
* @brief 循环滚动
|
||||
*/
|
||||
-(id)initLoopScrollWithFrame:(CGRect)frame withImageView:(NSMutableArray *)imageview;
|
||||
-(void)HDscrollViewDidScroll;
|
||||
-(void)HDscrollViewDidEndDecelerating;
|
||||
@end
|
||||
|
||||
@interface UIImageView (CopyImageview)<NSCoding>
|
||||
@end
|
||||
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
//
|
||||
// HdScrollView.m
|
||||
// ScrollView
|
||||
//
|
||||
// Created by Hu Di on 13-10-11.
|
||||
// Copyright (c) 2013年 Sanji. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HDScrollview.h"
|
||||
@interface HDScrollview()
|
||||
{
|
||||
BOOL loop;
|
||||
NSMutableArray *imageArray;
|
||||
}
|
||||
@end
|
||||
@implementation HDScrollview
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
self.showsHorizontalScrollIndicator = NO;
|
||||
self.showsVerticalScrollIndicator = NO;
|
||||
self.scrollsToTop = NO;
|
||||
self.pagingEnabled=YES;
|
||||
self.bounces=NO;
|
||||
self.userInteractionEnabled=YES;
|
||||
[self setContentOffset:CGPointMake(0, 0)];
|
||||
[self setContentOffset:CGPointMake(self.frame.size.width, 0)];
|
||||
UITapGestureRecognizer *Recognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
|
||||
Recognizer.numberOfTapsRequired=1;
|
||||
[self addGestureRecognizer:Recognizer];
|
||||
|
||||
if (!self.pagecontrol) {
|
||||
self.pagecontrol=[[HdPageControl alloc]init];
|
||||
self.pagecontrol.currentPage=0;//当前页数
|
||||
self.pagecontrol.userInteractionEnabled = YES;
|
||||
[self.pagecontrol addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame withImageView:(NSMutableArray *)imageviewarr
|
||||
{
|
||||
self = [self initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
}
|
||||
imageArray=imageviewarr;
|
||||
loop=NO;
|
||||
NSUInteger pageCount=[imageviewarr count];
|
||||
[self setContentSize:CGSizeMake(self.frame.size.width*pageCount, self.frame.size.height)];
|
||||
|
||||
CGRect bounds=self.frame;
|
||||
for (int i=0; i<pageCount; i++) {
|
||||
bounds.origin.x=bounds.size.width*i;
|
||||
UIImageView *imageview=[imageviewarr objectAtIndex:i];
|
||||
imageview.userInteractionEnabled=YES;
|
||||
imageview.frame=bounds;
|
||||
[self addSubview:imageview];
|
||||
}
|
||||
|
||||
self.pagecontrol.numberOfPages=pageCount;//总的图片页数
|
||||
NSLog(@"%d",self.pagecontrol.numberOfPages);
|
||||
[self.pagecontrol addObserver:self forKeyPath:@"currentPage" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:NULL];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initLoopScrollWithFrame:(CGRect)frame withImageView:(NSMutableArray *)ArrImageView
|
||||
{
|
||||
self = [self initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
|
||||
}
|
||||
loop=YES;
|
||||
imageArray=ArrImageView;
|
||||
NSMutableArray *tempArray=[NSMutableArray arrayWithArray:ArrImageView];
|
||||
//深拷贝imageview上的控件
|
||||
UIImageView *imageview1=[ArrImageView objectAtIndex:([ArrImageView count]-1)];
|
||||
UIImageView *imageview2=[ArrImageView objectAtIndex:0];
|
||||
NSData *data1=[NSKeyedArchiver archivedDataWithRootObject:imageview1];
|
||||
NSData *data2=[NSKeyedArchiver archivedDataWithRootObject:imageview2];
|
||||
UIImageView *imageview3=[NSKeyedUnarchiver unarchiveObjectWithData:data1];
|
||||
UIImageView *imageview4=[NSKeyedUnarchiver unarchiveObjectWithData:data2];
|
||||
[tempArray insertObject:imageview3 atIndex:0];
|
||||
[tempArray addObject:imageview4];
|
||||
NSUInteger pageCount=[tempArray count];
|
||||
[self setContentSize:CGSizeMake(self.frame.size.width*pageCount, self.frame.size.height)];
|
||||
|
||||
CGRect bounds=self.frame;
|
||||
for (int i=0; i<pageCount; i++) {
|
||||
bounds.origin.x=bounds.size.width*i;
|
||||
UIImageView *imageview=[tempArray objectAtIndex:i];
|
||||
imageview.userInteractionEnabled=YES;
|
||||
imageview.frame=bounds;
|
||||
[self addSubview:imageview];
|
||||
}
|
||||
self.pagecontrol.numberOfPages=pageCount-2;//总的图片页数
|
||||
[self.pagecontrol addObserver:self forKeyPath:@"currentPage" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:NULL];
|
||||
self.currentPageIndex = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setScrollInterval:(NSUInteger)scrollInterval
|
||||
{
|
||||
_scrollInterval = scrollInterval;
|
||||
|
||||
if (self.autoScrollTimer && self.autoScrollTimer.isValid) {
|
||||
[self.autoScrollTimer invalidate];
|
||||
self.autoScrollTimer = nil;
|
||||
}
|
||||
|
||||
self.autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:self.scrollInterval target:self selector:@selector(handleScrollTimer:) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
- (void)handleScrollTimer:(NSTimer *)timer
|
||||
{
|
||||
if (self.pagecontrol.numberOfPages == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// NSInteger currentPage = self.pagecontrol.currentPage;
|
||||
// NSInteger nextPage = currentPage + 1;
|
||||
// self.pagecontrol.currentPage++;
|
||||
// if (nextPage == self.pagecontrol.numberOfPages) {
|
||||
// nextPage = 0;
|
||||
// self.pagecontrol.currentPage = 0;
|
||||
// }
|
||||
self.currentPageIndex++;
|
||||
[self autoTurn];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)pageTurn:(UIPageControl *)sender
|
||||
{
|
||||
CGSize viewSize = self.frame.size;
|
||||
CGRect rect;
|
||||
if (loop) {
|
||||
rect = CGRectMake((sender.currentPage+1) * viewSize.width, 0, viewSize.width, viewSize.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = CGRectMake(sender.currentPage * viewSize.width, 0, viewSize.width, viewSize.height);
|
||||
}
|
||||
[self scrollRectToVisible:rect animated:YES];
|
||||
}
|
||||
-(void)autoTurn
|
||||
{
|
||||
CGSize viewSize = self.frame.size;
|
||||
CGRect rect = CGRectMake(self.currentPageIndex * viewSize.width, 0, viewSize.width, viewSize.height);
|
||||
|
||||
|
||||
[self scrollRectToVisible:rect animated:YES];
|
||||
|
||||
[self HDscrollViewDidScroll];
|
||||
[self HDscrollViewDidEndDecelerating];
|
||||
|
||||
}
|
||||
-(void)HDscrollViewDidScroll
|
||||
{
|
||||
if (loop) {
|
||||
CGFloat pageWidth = self.frame.size.width;
|
||||
int page = floor((self.contentOffset.x - pageWidth / 2) / pageWidth)+1;
|
||||
self.currentPageIndex=page;
|
||||
if (self.currentPageIndex == 5) {
|
||||
page = 1;
|
||||
}
|
||||
self.pagecontrol.currentPage=(page-1);
|
||||
}
|
||||
}
|
||||
|
||||
-(void)HDscrollViewDidEndDecelerating
|
||||
{
|
||||
if (self.autoScrollTimer && self.autoScrollTimer.isValid) {
|
||||
[self.autoScrollTimer invalidate];
|
||||
}
|
||||
self.autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:self.scrollInterval target:self selector:@selector(handleScrollTimer:) userInfo:nil repeats:YES];
|
||||
if (loop) {
|
||||
if (0==self.currentPageIndex) {
|
||||
[self setContentOffset:CGPointMake([imageArray count]*self.bounds.size.width, 0)];
|
||||
}
|
||||
if (([imageArray count]+1)==self.currentPageIndex) {
|
||||
[self setContentOffset:CGPointMake(self.bounds.size.width, 0)];
|
||||
[self HDscrollViewDidScroll];
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//更新UIPageControl的当前页
|
||||
CGPoint offset = self.contentOffset;
|
||||
CGRect bounds = self.frame;
|
||||
[self.pagecontrol setCurrentPage:offset.x / bounds.size.width];
|
||||
}
|
||||
}
|
||||
-(void)tap
|
||||
{
|
||||
[self.HDdelegate TapView:self.pagecontrol.currentPage];
|
||||
}
|
||||
|
||||
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
if ([keyPath isEqualToString:@"currentPage"]) {
|
||||
[self pageTurn:self.pagecontrol];
|
||||
[self.pagecontrol removeObserver:self forKeyPath:@"currentPage"];
|
||||
}
|
||||
}
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation UIImageView (CopyImageview)
|
||||
-(void)encodeWithCoder:(NSCoder *)aCoder
|
||||
{
|
||||
|
||||
[aCoder encodeObject:self.backgroundColor forKey:@"backgroundColor"];
|
||||
[aCoder encodeObject:self.image forKey:@"image"];
|
||||
[aCoder encodeInt:self.contentMode forKey:@"contentMode"];
|
||||
[aCoder encodeInt:self.subviews.count forKey:@"subviewscount"];
|
||||
for(int i=0;i<self.subviews.count;i++)
|
||||
{
|
||||
UIView *view=self.subviews[i];
|
||||
[aCoder encodeObject:view forKey:[NSString stringWithFormat:@"view%d",i]];
|
||||
}
|
||||
}
|
||||
-(id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
if (self=[super init]) {
|
||||
self.backgroundColor=[aDecoder decodeObjectForKey:@"backgroundColor"];
|
||||
self.image=[aDecoder decodeObjectForKey:@"image"];
|
||||
self.contentMode=[aDecoder decodeIntForKey:@"contentMode"];
|
||||
int subviewscount=[aDecoder decodeIntForKey:@"subviewscount"];
|
||||
for(int i=0;i<subviewscount;i++)
|
||||
{
|
||||
UIView* view=[aDecoder decodeObjectForKey:[NSString stringWithFormat:@"view%d",i]];
|
||||
[self addSubview:view];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// HdPageControl.h
|
||||
// ScrollView
|
||||
//
|
||||
// Created by Hu Di on 13-11-20.
|
||||
// Copyright (c) 2013年 Sanji. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface HdPageControl : UIPageControl
|
||||
@property (strong,nonatomic)UIColor *currentcolor;
|
||||
@property (strong,nonatomic)UIColor *othercolor;
|
||||
@end
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// HdPageControl.m
|
||||
// ScrollView
|
||||
//
|
||||
// Created by Hu Di on 13-11-20.
|
||||
// Copyright (c) 2013年 Sanji. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HdPageControl.h"
|
||||
#define IOS7 [[UIDevice currentDevice].systemVersion doubleValue]>=7.0
|
||||
@implementation HdPageControl
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void) updateDots
|
||||
{
|
||||
for (int i = 0; i < [self.subviews count]; i++)
|
||||
{
|
||||
UIView* pageIcon = [self.subviews objectAtIndex:i];
|
||||
pageIcon.layer.cornerRadius=3;
|
||||
pageIcon.layer.masksToBounds=YES;
|
||||
//NSLog(@"%@",NSStringFromClass([pageIcon class]));
|
||||
if ([NSStringFromClass([pageIcon class]) isEqualToString:@"UIImageView"]) {
|
||||
if (i == self.currentPage)
|
||||
{
|
||||
((UIImageView*)pageIcon).image=[self createImageWithColor:self.currentcolor];
|
||||
}
|
||||
else
|
||||
{
|
||||
((UIImageView*)pageIcon).image=[self createImageWithColor:self.othercolor];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == self.currentPage)
|
||||
{
|
||||
pageIcon.backgroundColor=self.currentcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
pageIcon.backgroundColor=self.othercolor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-(void) setCurrentPage:(NSInteger)page
|
||||
{
|
||||
[super setCurrentPage:page];
|
||||
[self updateDots];
|
||||
}
|
||||
- (UIImage *)createImageWithColor:(UIColor *)color
|
||||
{
|
||||
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
UIGraphicsBeginImageContext(rect.size);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
CGContextSetFillColorWithColor(context, [color CGColor]);
|
||||
CGContextFillRect(context, rect);
|
||||
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return theImage;
|
||||
}
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
@@ -7,7 +7,9 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ImagePlayerView.h"
|
||||
@interface HomeAdView : UIView<ImagePlayerViewDelegate>
|
||||
|
||||
#import "HDScrollview.h"
|
||||
@interface HomeAdView : UIView<HDScrollviewDelegate,UIScrollViewDelegate>
|
||||
{
|
||||
HDScrollview* _scrollview;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "HomeAdView.h"
|
||||
|
||||
#import "HDScrollview.h"
|
||||
@implementation HomeAdView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
@@ -16,12 +16,24 @@
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
ImagePlayerView* imagePlayerView = [[ImagePlayerView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
|
||||
imagePlayerView.autoScroll = YES;
|
||||
imagePlayerView.scrollInterval = 5;
|
||||
[imagePlayerView setPageControlPosition:ICPageControlPosition_BottomCenter];
|
||||
[imagePlayerView initWithCount:3 delegate:self];
|
||||
[self addSubview:imagePlayerView];
|
||||
NSArray *imageArray=@[[UIImage imageNamed:@"ad1"],[UIImage imageNamed:@"ad2"],[UIImage imageNamed:@"ad3"],[UIImage imageNamed:@"ad4"]];
|
||||
NSMutableArray* imageViewArray = [[NSMutableArray alloc] init];
|
||||
for (int i=0; i<imageArray.count; i++) {
|
||||
UIImageView *imageview=[[UIImageView alloc]init];
|
||||
imageview.image=[imageArray objectAtIndex:i];
|
||||
imageview.contentMode=UIViewContentModeScaleAspectFit;
|
||||
[imageViewArray addObject:imageview];
|
||||
}
|
||||
_scrollview=[[HDScrollview alloc]initLoopScrollWithFrame:frame withImageView:imageViewArray];
|
||||
_scrollview.delegate=self;
|
||||
_scrollview.HDdelegate=self;
|
||||
[self addSubview:_scrollview];
|
||||
_scrollview.pagecontrol.frame=CGRectMake(0, _scrollview.pagecontrol.frame.origin.y+_scrollview.frame.size.height-10, 320, 10);
|
||||
_scrollview.pagecontrol.currentcolor=[UIColor blackColor];
|
||||
_scrollview.pagecontrol.othercolor=[UIColor whiteColor];
|
||||
_scrollview.pagecontrol.currentPage=0;
|
||||
[_scrollview setScrollInterval:5];
|
||||
[self addSubview:_scrollview.pagecontrol];
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -33,12 +45,22 @@
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
#pragma mark ImagePlayerViewDelegate
|
||||
-(void)imagePlayerView:(ImagePlayerView *)imagePlayerView loadImageForImageView:(UIImageView *)imageView index:(NSInteger)index{
|
||||
|
||||
[imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"ad%ld",index+1]]];
|
||||
|
||||
#pragma mark ==========UIScrollViewDelegate============
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)sender
|
||||
{
|
||||
[_scrollview HDscrollViewDidScroll];
|
||||
}
|
||||
-(void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index{
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView
|
||||
{
|
||||
[_scrollview HDscrollViewDidEndDecelerating];
|
||||
}
|
||||
-(void)TapView:(int)index
|
||||
{
|
||||
DLog(@"点击了第%d个页面",index);
|
||||
//下面可以根据自己的需求操作
|
||||
//Example
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user