Skip to content

Commit

Permalink
Merge pull request #26 from manijak/master
Browse files Browse the repository at this point in the history
Added two new public properties
  • Loading branch information
zhangao0086 authored Mar 23, 2017
2 parents 613591a + 70b592b commit 046c1b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DKCarouselView/DKCarouselView.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ typedef void(^DKCarouselViewDidChangeBlock)(DKCarouselView *view, NSInteger inde
// indicator
@property (nonatomic, assign) BOOL indicatorIsVisible; // by default page indicator is visible
@property (nonatomic, strong) UIColor *indicatorTintColor;
@property (nonatomic, strong) UIColor *indicatorTintColorUnselected;
@property (nonatomic, assign) CGPoint indicatorOffset; // default offset is CGPointZero, the indicator is centered horizontally.
@property (nonatomic, readonly) CGSize indicatorSize; // returns minimum size for given items.
@property (nonatomic, readonly, weak) UIPageControl *pageControl;

@end
12 changes: 10 additions & 2 deletions DKCarouselView/DKCarouselView.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ @interface DKCarouselView () <UIScrollViewDelegate>
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, copy) NSArray *items;
@property (nonatomic, strong) NSMutableArray *carouselItemViews;
@property (nonatomic, weak) UIPageControl *pageControl;
@property (nonatomic, readwrite, weak) UIPageControl *pageControl;
@property (nonatomic, assign) CGSize lastSize;

@property (nonatomic, strong) NSTimer *autoPagingTimer;
Expand Down Expand Up @@ -125,10 +125,12 @@ - (void)commonInit {
scrollView.scrollsToTop = NO;
scrollView.delegate = self;

self.indicatorTintColor = [UIColor lightGrayColor];
self.indicatorTintColor = [UIColor whiteColor];
self.indicatorTintColorUnselected = [UIColor lightGrayColor];

UIPageControl *pageControl = [UIPageControl new];
pageControl.currentPageIndicatorTintColor = self.indicatorTintColor;
pageControl.pageIndicatorTintColor = self.indicatorTintColorUnselected;
pageControl.userInteractionEnabled = NO;

[self addSubview:scrollView];
Expand Down Expand Up @@ -202,6 +204,12 @@ - (void)setIndicatorTintColor:(UIColor *)indicatorTintColor {
self.pageControl.currentPageIndicatorTintColor = indicatorTintColor;
}

- (void)setIndicatorTintColorUnselected:(UIColor *)indicatorTintColorUnselected {
_indicatorTintColorUnselected = indicatorTintColorUnselected;

self.pageControl.pageIndicatorTintColor = indicatorTintColorUnselected;
}

- (CGSize)indicatorSize {
return [self.pageControl sizeForNumberOfPages:self.pageControl.numberOfPages];
}
Expand Down

0 comments on commit 046c1b0

Please sign in to comment.