Skip to content

Commit

Permalink
add title updating method
Browse files Browse the repository at this point in the history
  • Loading branch information
iTofu committed Mar 5, 2019
1 parent 12e6080 commit 6676370
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Demo/LCActionSheetDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ - (IBAction)showBlockActionSheet {

[actionSheet show];


// Append buttons methods
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2.0f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
// [actionSheet appendButtonWithTitle:@"WoW" atIndex:7];
Expand All @@ -179,6 +179,8 @@ - (IBAction)showBlockActionSheet {
[set addIndex:1];
[set addIndex:2];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexes:set];

// [actionSheet setButtonTitle:@"New Title" atIndex:1];
});
}

Expand Down
4 changes: 2 additions & 2 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- LCActionSheet (3.5.2):
- LCActionSheet (3.5.3):
- Masonry (~> 1.1.0)
- Masonry (1.1.0)
- Reveal-SDK (20)
Expand All @@ -18,7 +18,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
LCActionSheet: 78c62150c088d83ad219760a950abd7349cea832
LCActionSheet: e78060016fb0964959934f8e0e4b9c933395edd1
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
Reveal-SDK: 43206a57f575632fd304e85385cc259b5d359e32

Expand Down
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 = "3.5.2"
s.version = "3.5.3"
s.summary = "A simple, ornamental, but powerful action sheet! Support: https://LeoDev.me"
s.homepage = "https://github.com/iTofu/LCActionSheet"
s.license = "MIT"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ In me the tiger sniffs the rose.
[set addIndex:1];
[set addIndex:2];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexes:set];

// [actionSheet setButtonTitle:@"New Title" atIndex:1];
});

[actionSheet show];
Expand Down Expand Up @@ -302,6 +304,10 @@ In me the tiger sniffs the rose.

## 版本 ChangeLog

### [V 3.5.3](https://github.com/iTofu/LCActionSheet/releases/tag/3.5.3) (2019.03.05)

* 增加 `- (void)setButtonTitle:(NSString *)title atIndex:(NSInteger)index;` 方法

### [V 3.5.2](https://github.com/iTofu/LCActionSheet/releases/tag/3.5.2) (2019.03.05)

* 增加 `disableAutoDismissAfterClicking`,控制是否在点击有效项后自动消失,默认 `NO`,自动消失
Expand Down
13 changes: 10 additions & 3 deletions Source/LCActionSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,21 @@ typedef void(^LCActionSheetDidDismissHandler)(LCActionSheet *actionSheet, NSInte
- (void)show;

/**
Get button title with index
Get button title with index.
@param index index
@return button title
*/
- (NSString *)buttonTitleAtIndex:(NSInteger)index;
- (nullable NSString *)buttonTitleAtIndex:(NSInteger)index;

/**
Set button title with index.
@param title title
@param index index
*/
- (void)setButtonTitle:(nullable NSString *)title atIndex:(NSInteger)index;

@end

NS_ASSUME_NONNULL_END

16 changes: 16 additions & 0 deletions Source/LCActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,22 @@ - (NSString *)buttonTitleAtIndex:(NSInteger)index {
return buttonTitle;
}

- (void)setButtonTitle:(NSString *)title atIndex:(NSInteger)index {
if (index < 0 || index - 1 >= self.otherButtonTitles.count) {
return;
}
if (index == 0) {
self.cancelButtonTitle = title;
} else {
NSMutableArray<NSString *> *arrayM = self.otherButtonTitles.mutableCopy;
arrayM[index - 1] = title;
self.otherButtonTitles = arrayM.copy;
[self.tableView reloadData];
[self updateBottomView];
[self updateTableView];
}
}

#pragma mark - Update Views

- (void)updateBottomView {
Expand Down

0 comments on commit 6676370

Please sign in to comment.