ios - 纹理 ASTextNode 边框和阴影属性不起作用
问题描述
这是我的代码,我ASTextNode
在我的超级视图上放了一个并应用了一些属性,但其中一些不起作用,例如ASTextBorder
.
CGFloat top = 10;
CGFloat bottom = -1;
UIEdgeInsets insets = UIEdgeInsetsMake(top, -10, bottom, -10);
CGFloat radius = font.pointSize / 2;
mps.alignment = textAlignment; //NSMutableParagraphStyle
ASTextNode *textNode = [ASTextNode new];
ASTextBorder *asBorder = [ASTextBorder borderWithFillColor:UIColor.redColor cornerRadius:radius];
asBorder.insets = insets;
NSDictionary *attributes = @{
NSForegroundColorAttributeName: UIColor.whiteColor,
NSFontAttributeName: font,
NSStrokeWidthAttributeName: @(-5),
NSStrokeColorAttributeName: UIColor.blackColor,
NSParagraphStyleAttributeName: mps,
ASTextBorderAttributeName: asBorder,
};
textNode.attributedText = [[NSAttributedString alloc] initWithString:text attributes:attributes];
textNode.textContainerInset = UIEdgeInsetsMake(0, 10, 5, 10);
return textNode;
字典中指定的其余属性执行正常。
谁能解释为什么?谢谢。
解决方案
事实证明,自定义属性在 ASTextNode2 中可用并由开关控制。
推荐阅读
- excel - 按下 MS Word 或 Excel 中的“拼音指南”按钮时会调用哪个 VBA 函数或宏?
- python - 如何创建一个自动安装一些库的python程序
- javascript - 为什么 innerHTML 会截断我的字符串(以及如何修复它)?
- asp.net - 使用 Github Actions 发布 React+dotnet 核心应用程序抛出错误 MSB3073: The command "npm run build" exited with code 1
- shopify - Shopify 如何检查产品是否存在于购物车中
- c - C 代码在 VS 中工作,但在通过 valgrind 时失败并拒绝编译
- javascript - 以编程方式在 Material-UI 的数据网格中预选一行(React)
- sql - 查找最后一个和倒数第二个日期和相应的值
- javascript - 计算整体锻炼时间的“持续时间”
- python - 根据列表中的部分匹配字符串过滤 DataFrame