diff --git a/BRAdmob/BRAdmob/BRAdmobView.h b/BRAdmob/BRAdmob/BRAdmobView.h index 2f7fe95..3db9642 100644 --- a/BRAdmob/BRAdmob/BRAdmobView.h +++ b/BRAdmob/BRAdmob/BRAdmobView.h @@ -18,6 +18,13 @@ typedef void(^admobSelectBlcok)(id info,NSInteger index); + +typedef NS_ENUM(NSUInteger, KPageControlPostion) { + KPageControlPostion_Left=1, + KPageControlPostion_Middle, + KPageControlPostion_right +}; + @interface BRAdmobView : UIView { NSInteger indexScoller; @@ -76,8 +83,7 @@ typedef void(^admobSelectBlcok)(id info,NSInteger index); * * @param size <#size description#> */ --(void)addPageControlViewWithSize:(CGSize)size; - +-(void)addPageControlViewWithSize:(CGSize)size WithPostion:(KPageControlPostion)postion; /** * 刷新数据,并且刷新PageControl * diff --git a/BRAdmob/BRAdmob/BRAdmobView.m b/BRAdmob/BRAdmob/BRAdmobView.m index 3a30087..eac4632 100644 --- a/BRAdmob/BRAdmob/BRAdmobView.m +++ b/BRAdmob/BRAdmob/BRAdmobView.m @@ -67,7 +67,7 @@ -(void)addColletionViewInView:(UIView*)view{ _titileLabel.textAlignment=NSTextAlignmentCenter; //0,6,192,21; } --(void)addPageControlViewWithSize:(CGSize)size +-(void)addPageControlViewWithSize:(CGSize)size WithPostion:(KPageControlPostion)postion { @@ -78,7 +78,22 @@ -(void)addPageControlViewWithSize:(CGSize)size float witdth=size.width* self.dataArray.count + margin*(self.dataArray.count-1); float height=size.height; - self.pageControl=[[UIPageControl alloc] initWithFrame:CGRectMake(self.frame.size.width-witdth, self.frame.size.height-height-(32-height)/2, witdth, height)]; + + + CGRect frame=CGRectMake(self.frame.size.width-witdth, self.frame.size.height-height-(32-height)/2, witdth, height); + + if (postion==KPageControlPostion_Left) { + + + frame.origin.x=5; + + } + else if (postion==KPageControlPostion_Middle){ + + frame.origin.x=(self.frame.size.width-witdth)/2; + } + + self.pageControl=[[UIPageControl alloc] initWithFrame:frame]; self.pageControl.numberOfPages=self.dataArray.count; self.pageControl.currentPage=0; diff --git a/BRAdmob/ViewController.m b/BRAdmob/ViewController.m index 51da2be..be95e84 100644 --- a/BRAdmob/ViewController.m +++ b/BRAdmob/ViewController.m @@ -41,7 +41,7 @@ - (void)viewDidLoad { BRAdmobView * view=[[BRAdmobView alloc] initWithFrame:CGRectMake(10, 64, 300, 150) andData:@[info1,info2,info3,info4,info5] andInViewe:self.view]; - [view addPageControlViewWithSize:CGSizeMake(10, 10)]; + [view addPageControlViewWithSize:CGSizeMake(10, 10) WithPostion:KPageControlPostion_Left]; view.isAutoScoller=YES; [self.view addSubview:view];