有没有人对如何裁剪出现在聚光灯搜索中的图像有任何想法,以便“thumbnailData”是圆形图像而不是方形图像?
这些解决方案都没有达到预期的效果:将 UIImage 切成圆形 Swift(iOS)
我可以成功裁剪图像,但聚光灯功能会在裁剪/蒙版边框周围放置一个白色背景。聚光灯联系人(kUTTypeContact)是可能的,而不是我所看到的内容(kUTTypeContent)。
这是我的代码,供任何研究人员查看:
// For storing attributes into Searchable Dictionary
internal var attributeSet: CSSearchableItemAttributeSet {
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeContent as String)
attributeSet.title = "\(firstName) \(surname)"
attributeSet.contentDescription = location
attributeSet.keywords = ["tennis", "scorelord", firstName, surname, handed, location, "\(itnLevel)"]
attributeSet.thumbnailData = UIImageJPEGRepresentation(profileImage, 0.8)
attributeSet.thumbnailData?.displayLayer(<#T##layer: CALayer##CALayer#>)
return attributeSet
}