添加功能组件
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
UIButton *btn = [self buildButtonWithTitle:(i < self.leftTitles.count ? self.leftTitles[i] : [NSString stringWithFormat:@"L%ld", (long)i])];
|
||||
btn.tag = 100 + i;
|
||||
[btn addTarget:self action:@selector(onLeftTap:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.leftContainer addSubview:btn];
|
||||
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
if (prev) {
|
||||
@@ -84,6 +85,7 @@
|
||||
UIButton *btn = [self buildButtonWithTitle:(i < self.rightTitles.count ? self.rightTitles[i] : [NSString stringWithFormat:@"R%ld", (long)i])];
|
||||
btn.tag = 200 + i;
|
||||
[self.rightContainer addSubview:btn];
|
||||
[btn addTarget:self action:@selector(onRightTap:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[rightBtns addObject:btn];
|
||||
}
|
||||
|
||||
@@ -112,6 +114,22 @@
|
||||
self.rightButtonsInternal = rightBtns.copy;
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)onLeftTap:(UIButton *)sender {
|
||||
NSInteger idx = sender.tag - 100;
|
||||
if ([self.delegate respondsToSelector:@selector(functionBarView:didTapLeftAtIndex:)]) {
|
||||
[self.delegate functionBarView:self didTapLeftAtIndex:idx];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onRightTap:(UIButton *)sender {
|
||||
NSInteger idx = sender.tag - 200;
|
||||
if ([self.delegate respondsToSelector:@selector(functionBarView:didTapRightAtIndex:)]) {
|
||||
[self.delegate functionBarView:self didTapRightAtIndex:idx];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIButton *)buildButtonWithTitle:(NSString *)title {
|
||||
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
btn.layer.cornerRadius = 18;
|
||||
|
||||
Reference in New Issue
Block a user