Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DSCircularCollectionView/Classes/DSCircularLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@property (nonatomic, assign) BOOL rotateItems;

-(void)initWithCentre:(CGPoint)centre radius:(CGFloat)radius itemSize:(CGSize)itemSize andAngularSpacing:(CGFloat)angularSpacing;
-(void)initWithCentre:(CGPoint)centre radius:(CGFloat)radius itemSize:(CGSize)itemSize andAngularSpacing:(CGFloat)angularSpacing isCountingWidth:(BOOL)isCountingWidth;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave the previous init as is and add this as another init so that the existing users can still be supported. Also, make sure you set isCountingWidth to NO in the older init implementation.


-(void)setStartAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle;

Expand Down
12 changes: 10 additions & 2 deletions DSCircularCollectionView/Classes/DSCircularLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ @implementation DSCircularLayout{

CGFloat _startAngle;
CGFloat _endAngle;

BOOL _isCountingWidth;
}

- (id)init {
Expand All @@ -28,11 +30,12 @@ - (id)init {
return self;
}

-(void)initWithCentre:(CGPoint)centre radius:(CGFloat)radius itemSize:(CGSize)itemSize andAngularSpacing:(CGFloat)angularSpacing{
-(void)initWithCentre:(CGPoint)centre radius:(CGFloat)radius itemSize:(CGSize)itemSize andAngularSpacing:(CGFloat)angularSpacing isCountingWidth:(BOOL)isCountingWidth {
_centre = centre;
_radius = radius;
_itemSize = itemSize;
_angularSpacing = angularSpacing;
_isCountingWidth = isCountingWidth;
}

-(void)setStartAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle{
Expand All @@ -50,7 +53,12 @@ -(void)prepareLayout{
[super prepareLayout];
cellCount = [self.collectionView numberOfItemsInSection:0];
circumference = ABS(_startAngle - _endAngle)*_radius;
maxNoOfCellsInCircle = circumference/(MAX(_itemSize.width, _itemSize.height) + _angularSpacing/2);

if (_isCountingWidth) {
maxNoOfCellsInCircle = circumference/(MAX(_itemSize.width, _itemSize.height) + _angularSpacing/2);
} else {
maxNoOfCellsInCircle = circumference/(_itemSize.height + _angularSpacing/2);
}
angleOfEachItem = ABS(_startAngle - _endAngle)/maxNoOfCellsInCircle;
}

Expand Down