Skip to content

Commit

Permalink
improve #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo committed Jan 3, 2017
1 parent afd4872 commit b8ee8d8
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LCActionSheet.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "LCActionSheet"
s.version = "2.7.0"
s.version = "2.7.1"
s.summary = "A simple, ornamental, but powerful action sheet! Support: http://LeoDev.me"
s.homepage = "https://github.com/iTofu/LCActionSheet"
s.license = "MIT"
Expand Down
7 changes: 6 additions & 1 deletion LCActionSheet/LCActionSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// GitHub: http://github.com/iTofu
// Mail: mailto:devtip@163.com
//
// V 2.7.0
// V 2.7.1

#import <UIKit/UIKit.h>
#import "LCActionSheetConfig.h"
Expand Down Expand Up @@ -178,6 +178,11 @@ typedef void(^LCActionSheetDidDismissHandle)(LCActionSheet *actionSheet, NSInteg
*/
@property (nonatomic, assign) UIEdgeInsets titleEdgeInsets;

/**
* Cell's separator color. Default is `RGBA(170/255.0f, 170/255.0f, 170/255.0f, 0.5f)`.
*/
@property (nonatomic, strong) UIColor *separatorColor;


/**
* LCActionSheet clicked handle.
Expand Down
19 changes: 15 additions & 4 deletions LCActionSheet/LCActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ - (instancetype)config:(LCActionSheetConfig *)config {
_unBlur = config.unBlur;
_blurEffectStyle = config.blurEffectStyle;
_titleEdgeInsets = config.titleEdgeInsets;
_separatorColor = config.separatorColor;

return self;
}
Expand Down Expand Up @@ -280,7 +281,7 @@ - (void)setupView {


UIView *lineView = [[UIView alloc] init];
lineView.backgroundColor = LC_ACTION_SHEET_CELL_LINE_COLOR;
lineView.backgroundColor = self.separatorColor;
lineView.contentMode = UIViewContentModeBottom;
lineView.clipsToBounds = YES;
[bottomView addSubview:lineView];
Expand Down Expand Up @@ -312,10 +313,8 @@ - (void)setupView {
cancelButton.titleLabel.font = self.buttonFont;
[cancelButton setTitle:self.cancelButtonTitle forState:UIControlStateNormal];
[cancelButton setTitleColor:self.buttonColor forState:UIControlStateNormal];
[cancelButton setBackgroundImage:[UIImage imageWithColor:LC_ACTION_SHEET_CELL_LINE_COLOR]
[cancelButton setBackgroundImage:[UIImage imageWithColor:self.separatorColor]
forState:UIControlStateHighlighted];
[cancelButton setBackgroundImage:[UIImage imageWithColor:LC_ACTION_SHEET_CELL_LINE_COLOR]
forState:UIControlStateSelected];
[cancelButton addTarget:self
action:@selector(cancelButtonClicked)
forControlEvents:UIControlEventTouchUpInside];
Expand Down Expand Up @@ -519,6 +518,15 @@ - (void)setTitleEdgeInsets:(UIEdgeInsets)titleEdgeInsets {
[self updateTableView];
}

- (void)setSeparatorColor:(UIColor *)separatorColor {
_separatorColor = separatorColor;

self.lineView.backgroundColor = separatorColor;
[self.cancelButton setBackgroundImage:[UIImage imageWithColor:separatorColor]
forState:UIControlStateHighlighted];
[self.tableView reloadData];
}

- (CGSize)titleTextSize {
CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width -
(self.titleEdgeInsets.left + self.titleEdgeInsets.right),
Expand Down Expand Up @@ -683,6 +691,7 @@ - (void)cancelButtonClicked {
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];

if ([self.delegate respondsToSelector:@selector(actionSheet:clickedButtonAtIndex:)]) {
[self.delegate actionSheet:self clickedButtonAtIndex:indexPath.row + 1];
Expand Down Expand Up @@ -712,6 +721,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell.titleLabel.text = self.otherButtonTitles[indexPath.row];

cell.cellSeparatorColor = self.separatorColor;

// cell.lineView.hidden = indexPath.row == MAX(self.otherButtonTitles.count - 1, 0);

if (indexPath.row == MAX(self.otherButtonTitles.count - 1, 0)) {
Expand Down
7 changes: 5 additions & 2 deletions LCActionSheet/LCActionSheetCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#define LC_ACTION_SHEET_CELL_NO_HIDDE_LINE_TAG 100
#define LC_ACTION_SHEET_CELL_HIDDE_LINE_TAG 101

#define LC_ACTION_SHEET_CELL_LINE_COLOR LC_ACTION_SHEET_COLOR_A(170, 170, 170, 0.5f)


@interface LCActionSheetCell : UITableViewCell

Expand All @@ -27,4 +25,9 @@
*/
@property (nonatomic, weak) UIView *lineView;

/**
* Cell's separator color.
*/
@property (nonatomic, strong) UIColor *cellSeparatorColor;

@end
15 changes: 10 additions & 5 deletions LCActionSheet/LCActionSheetCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
self.backgroundColor = [UIColor clearColor];

UIView *highlightedView = [[UIView alloc] init];
highlightedView.backgroundColor = LC_ACTION_SHEET_CELL_LINE_COLOR;
highlightedView.clipsToBounds = YES;
highlightedView.hidden = YES;
highlightedView.backgroundColor = self.cellSeparatorColor;
highlightedView.clipsToBounds = YES;
highlightedView.hidden = YES;
[self.contentView addSubview:highlightedView];
self.highlightedView = highlightedView;
[highlightedView mas_makeConstraints:^(MASConstraintMaker *make) {
Expand All @@ -45,7 +45,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
}];

UIView *lineView = [[UIView alloc] init];
lineView.backgroundColor = LC_ACTION_SHEET_CELL_LINE_COLOR;
lineView.backgroundColor = self.cellSeparatorColor;
lineView.contentMode = UIViewContentModeBottom;
lineView.clipsToBounds = YES;
[self.contentView addSubview:lineView];
Expand All @@ -58,7 +58,12 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {}
- (void)setCellSeparatorColor:(UIColor *)cellSeparatorColor {
_cellSeparatorColor = cellSeparatorColor;

self.highlightedView.backgroundColor = cellSeparatorColor;
self.lineView.backgroundColor = cellSeparatorColor;
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
if (self.tag == LC_ACTION_SHEET_CELL_HIDDE_LINE_TAG) {
Expand Down
5 changes: 5 additions & 0 deletions LCActionSheet/LCActionSheetConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
*/
@property (nonatomic, assign) UIEdgeInsets titleEdgeInsets;

/**
* Cell's separator color. Default is `RGBA(170/255.0f, 170/255.0f, 170/255.0f, 0.5f)`.
*/
@property (nonatomic, strong) UIColor *separatorColor;


/**
LCActionSheetConfig instance.
Expand Down
6 changes: 4 additions & 2 deletions LCActionSheet/LCActionSheetConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ - (instancetype)init {
self.destructiveButtonColor = LC_ACTION_SHEET_RED_COLOR;
self.titleColor = LC_ACTION_SHEET_COLOR(111, 111, 111);
self.buttonColor = [UIColor blackColor];

self.buttonHeight = LC_ACTION_SHEET_BUTTON_HEIGHT;
self.animationDuration = LC_ACTION_SHEET_ANIMATION_DURATION;
self.darkOpacity = LC_ACTION_SHEET_DARK_OPACITY;

self.titleEdgeInsets = UIEdgeInsetsMake(15.0f, 15.0f, 15.0f, 15.0f);

self.separatorColor = LC_ACTION_SHEET_COLOR_A(170, 170, 170, 0.5f);
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion LCActionSheetDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.7.0</string>
<string>2.7.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
3 changes: 3 additions & 0 deletions LCActionSheetDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ - (IBAction)showCustomActionSheet {
// V 2.7.0+
actionSheet.titleEdgeInsets = UIEdgeInsetsMake(10, 20, 30, 40);

// V 2.7.1+
actionSheet.separatorColor = [UIColor orangeColor];

[actionSheet show];
}

Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ In me the tiger sniffs the rose.
// V 2.7.0+
actionSheet.titleEdgeInsets = UIEdgeInsetsMake(10, 20, 30, 40);

// V 2.7.1+
actionSheet.separatorColor = [UIColor orangeColor];

[actionSheet show];
```

Expand Down Expand Up @@ -223,6 +226,21 @@ In me the tiger sniffs the rose.
## 版本 ChangeLog
### V 2.7.1 (2017.01.03)
* 新年快乐~
* 添加 `separatorColor` 属性,默认值 `RGBA(170/255.0f, 170/255.0f, 170/255.0f, 0.5f)`,[#30](https://github.com/iTofu/LCActionSheet/issues/30) by [Abel94](https://github.com/Abel94):
```objc
@interface LCActionSheet : UIView
@property (nonatomic, strong) UIColor *separatorColor;
@end
```


### V 2.7.0 (2016.11.29)

* 新增 [LCActionSheetConfig](https://github.com/iTofu/LCActionSheet/blob/master/LCActionSheet/LCActionSheetConfig.h) 类,用来统一配置 LCActionSheet 的样式(参数),使用方式见 [Usage](https://github.com/iTofu/LCActionSheet#代码-usage)[#29](https://github.com/iTofu/LCActionSheet/issues/29) by [Abel94](https://github.com/Abel94)
Expand Down

0 comments on commit b8ee8d8

Please sign in to comment.