You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 15系统的imageVariant属性具体位于哪个类中?

你要找的 imageVariant 属于 UIImage.Configuration 类,是iOS 15及更高版本推出的SF Symbols相关API,并非UIView类的属性。

该属性用于控制SF Symbols的显示变体,常见的变体类型包括填充、描边、斜体等,使用时需要将携带对应imageVariant的配置赋值给UIImage实例,再绑定到UIImageView等控件上即可生效。

参考使用代码示例:

// 生成填充变体配置
let filledConfig = UIImage.Configuration.variant(filled: true)
// 组合符号尺寸配置与变体配置
let finalConfig = UIImage.SymbolConfiguration(pointSize: 20, weight: .medium)
    .applying(filledConfig)
// 生成配置后的SF Symbol图片
let image = UIImage(systemName: "heart", withConfiguration: finalConfig)
// 赋值给UIImageView
yourImageView.image = image

内容的提问来源于stack exchange,提问作者matt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 00:24:04