减小 UITableViewRowAction 的字体大小
Reduce font size for UITableViewRowAction
查看 Apple "Mail" 应用程序时,行操作的字体比默认字体小 20% 左右。如何在 swift 中获得相同的字体大小?
这是视图层次结构:
<UITableViewCellDeleteConfirmationView: 0x14ed4edf0; frame = (320 0; 254 77.5); clipsToBounds = YES; autoresize = H; layer = <CALayer: 0x170620340>>
| <_UITableViewCellActionButton: 0x14ed190f0; frame = (155 0; 99 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170622a00>>
| | <UIButtonLabel: 0x14ed36920; frame = (15 28; 69 21.5); text = 'Delete'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17029ce30>>
| <_UITableViewCellActionButton: 0x14ed50380; frame = (71.5 0; 83.5 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170436ec0>>
| | <UIButtonLabel: 0x14ed45a50; frame = (15 28; 53.5 21.5); text = 'Edit'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17009d4c0>>
| <_UITableViewCellActionButton: 0x14ed5a320; frame = (0 0; 71.5 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170439940>>
| | <UIButtonLabel: 0x14ed422b0; frame = (15 28; 41.5 21.5); text = 'More'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x170296760>>
我可以通过某种方式访问 UIButtonLabels 吗?
到目前为止尝试过:
我尝试更改外观,但似乎没有为此元素定义。
为 UILabel 编写一个扩展来更改 layoutSubviews 上的字体,但它也更改了所有其他 UILabel。
目标代码
+ (NSArray*)findAllButtonLabelFromCell:(UITableViewCell*)cell {
NSMutableArray* buttonLabels = [[NSMutableArray alloc]init];
[self addButtonLabelToArray:buttonLabels view:cell];
return buttonLabels;
}
+ (void)addButtonLabelToArray:(NSMutableArray*)arr view:(UIView*)view {
//For pass Apple examine
//contact the name in runtime
NSString* prefix = @"UIButton";
NSString* suffix = @"Label";
NSString* name = [prefix stringByAppendingString:suffix];
for (UIView* subView in view.subviews) {
if ([subView isKindOfClass:NSClassFromString(name)]) {
[arr addObject:subView];
}
[self addButtonLabelToArray:arr view:subView];
}
}
并且您应该使用 UILabel
访问 return 数组元素
查看 Apple "Mail" 应用程序时,行操作的字体比默认字体小 20% 左右。如何在 swift 中获得相同的字体大小?
这是视图层次结构:
<UITableViewCellDeleteConfirmationView: 0x14ed4edf0; frame = (320 0; 254 77.5); clipsToBounds = YES; autoresize = H; layer = <CALayer: 0x170620340>>
| <_UITableViewCellActionButton: 0x14ed190f0; frame = (155 0; 99 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170622a00>>
| | <UIButtonLabel: 0x14ed36920; frame = (15 28; 69 21.5); text = 'Delete'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17029ce30>>
| <_UITableViewCellActionButton: 0x14ed50380; frame = (71.5 0; 83.5 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170436ec0>>
| | <UIButtonLabel: 0x14ed45a50; frame = (15 28; 53.5 21.5); text = 'Edit'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17009d4c0>>
| <_UITableViewCellActionButton: 0x14ed5a320; frame = (0 0; 71.5 77.5); opaque = NO; autoresize = H; layer = <CALayer: 0x170439940>>
| | <UIButtonLabel: 0x14ed422b0; frame = (15 28; 41.5 21.5); text = 'More'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x170296760>>
我可以通过某种方式访问 UIButtonLabels 吗?
到目前为止尝试过:
我尝试更改外观,但似乎没有为此元素定义。
为 UILabel 编写一个扩展来更改 layoutSubviews 上的字体,但它也更改了所有其他 UILabel。
目标代码
+ (NSArray*)findAllButtonLabelFromCell:(UITableViewCell*)cell {
NSMutableArray* buttonLabels = [[NSMutableArray alloc]init];
[self addButtonLabelToArray:buttonLabels view:cell];
return buttonLabels;
}
+ (void)addButtonLabelToArray:(NSMutableArray*)arr view:(UIView*)view {
//For pass Apple examine
//contact the name in runtime
NSString* prefix = @"UIButton";
NSString* suffix = @"Label";
NSString* name = [prefix stringByAppendingString:suffix];
for (UIView* subView in view.subviews) {
if ([subView isKindOfClass:NSClassFromString(name)]) {
[arr addObject:subView];
}
[self addButtonLabelToArray:arr view:subView];
}
}
并且您应该使用 UILabel
访问 return 数组元素