Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.07k stars 1.37k forks source link

QMUIEmptyView空数据提示没办法设置按钮的宽度、圆角 #1277

Closed firenessZX closed 2 years ago

firenessZX commented 3 years ago

空数据提示QMUIEmptyView中图片、提示文字、刷新按钮,按钮无法设置宽度,圆角,阴影等。好像文字的宽度就是按钮的宽度,希望增加类似的API可以设置按钮的宽度、圆角、阴影等。

xixisplit commented 2 years ago

actionButton 如果有圆角需求.你可以尝试通过 qmui_imageWithAttributedString 将NSMutableAttributedString转为一张图片. 然后对图片设置圆角.或者参照一下我的例子尝试 [self.tableView showEmptyViewWithLoading:NO image:UIImageNameMake(@"JL_report_illustration_record") text:@"暂无数据" detailText:nil buttonTitle:@"" buttonAction:nil]; [self.tableView.emptyView setActionButtonTitleColor:UIColor.redColor]; UIImage *image = [UIImage qmui_imageWithSize:(CGSizeMake(100, 40)) opaque:NO scale:2 actions:^(CGContextRef _Nonnull contextRef) { NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:@"重新请求"]; UIImage *temp = [UIImage qmui_imageWithAttributedString:attr]; [temp drawAtPoint:(CGPointMake((100-temp.size.width)/2, (40-temp.size.height)/2))]; }]; image = [image qmui_imageWithBorderColor:UIColor.blackColor borderWidth:1 cornerRadius:20]; [self.tableView.emptyView.actionButton setImage:image forState:(UIControlStateNormal)];

MoLice commented 2 years ago

actionButton 的宽度可通过 contentEdgeInsets 调整,圆角、阴影可以自行修改 actionButton.layer.cornerRadius、actionButton.layer.shadowXxx。 这些都可以写在 showEmptyView 内。