Skip to content

Commit

Permalink
Add optional top and bottom margin properties for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Mar 20, 2016
1 parent ba63128 commit ce0e420
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions MGSwipeTableCell/MGSwipeTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ typedef NS_ENUM(NSInteger, MGSwipeEasingFunction) {
** For example it can be used to avoid cropped buttons when sectionIndexTitlesForTableView is used in the UITableView
**/
@property (nonatomic, assign) CGFloat offset;
/** Top margin of the buttons relative to the contentView */
@property (nonatomic, assign) CGFloat topMargin;
/** Bottom margin of the buttons relative to the contentView */
@property (nonatomic, assign) CGFloat bottomMargin;

/** Animation settings when the swipe buttons are shown */
@property (nonatomic, strong) MGSwipeAnimation * showAnimation;
/** Animation settings when the swipe buttons are hided */
Expand Down
8 changes: 4 additions & 4 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -702,16 +702,16 @@ -(void) createSwipeViewIfNeeded
[self fetchButtonsIfNeeded];
if (!_leftView && _leftButtons.count > 0) {
_leftView = [[MGSwipeButtonsView alloc] initWithButtons:_leftButtons direction:MGSwipeDirectionLeftToRight differentWidth:_allowsButtonsWithDifferentWidth];
_leftView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
_leftView.cell = self;
_leftView.frame = CGRectMake(-_leftView.bounds.size.width, 0, _leftView.bounds.size.width, _swipeOverlay.bounds.size.height);
_leftView.frame = CGRectMake(-_leftView.bounds.size.width, _leftSwipeSettings.topMargin, _leftView.bounds.size.width, _swipeOverlay.bounds.size.height - _leftSwipeSettings.topMargin - _leftSwipeSettings.bottomMargin);
_leftView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
[_swipeOverlay addSubview:_leftView];
}
if (!_rightView && _rightButtons.count > 0) {
_rightView = [[MGSwipeButtonsView alloc] initWithButtons:_rightButtons direction:MGSwipeDirectionRightToLeft differentWidth:_allowsButtonsWithDifferentWidth];
_rightView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
_rightView.cell = self;
_rightView.frame = CGRectMake(_swipeOverlay.bounds.size.width, 0, _rightView.bounds.size.width, _swipeOverlay.bounds.size.height);
_rightView.frame = CGRectMake(_swipeOverlay.bounds.size.width, _rightSwipeSettings.topMargin, _rightView.bounds.size.width, _swipeOverlay.bounds.size.height - _rightSwipeSettings.topMargin - _rightSwipeSettings.bottomMargin);
_rightView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[_swipeOverlay addSubview:_rightView];
}
}
Expand Down

0 comments on commit ce0e420

Please sign in to comment.