gpt4 book ai didi

ios - Swift ios 中的自定义谷歌地图标记图标图像

转载 作者:行者123 更新时间:2023-11-30 13:18:25 25 4
gpt4 key购买 nike

我正在将自定义 View 加载从 xib 转换为 UIImage 以显示为标记图标。它已完成,但问题是在 for 循环中执行此操作以显示 100 个标记时 UI 会卡住吗?因为加载 xib 自定义 View ?

下面是for循环中调用的函数

func generateSpot(Prop: Property) -> Spot {

let latStr = Prop.propLat
let langStr = Prop.propLang as NSString
let langDbl : Double = Double(langStr.floatValue)
let latDbl : Double = Double(latStr.floatValue)

let marker:GMSMarker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(langDbl,latDbl)
marker.appearAnimation = kGMSMarkerAnimationPop
marker.title = Prop.propBuildingName as String
marker.snippet = Prop.propCode as String
marker.infoWindowAnchor = CGPointMake(0.44, 0.45)

let sizeVar:CGSize = CGSize(width: 41, height: 37)

let customeMarker :CustomMarker = NSBundle.mainBundle().loadNibNamed("CustomView", owner: self.view, options: nil).first! as! CustomMarker

customeMarker.frame = CGRectMake(customeMarker.frame.minX,customeMarker.frame.minY,customeMarker.frame.width,customeMarker.frame.height)
customeMarker.mappedNumbers.layer.masksToBounds = true
customeMarker.mappedNumbers.layer.cornerRadius = 8
customeMarker.mappedNumbers.text = Prop.propSequence as String

if Prop.propStatus == self.constants!.status.STATUS_COMPLETED_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0x70b420)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420)
}

if Prop.propStatus == self.constants!.status.STATUS_DRAFT_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd2cb46)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420)


}
if Prop.propStatus == self.constants!.status.STATUS_PENDING_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd44646)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0xd44646)


}


UIGraphicsBeginImageContextWithOptions(sizeVar, false, 0)
customeMarker.drawViewHierarchyInRect(customeMarker.bounds, afterScreenUpdates: true)

let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
marker.icon = newImage
marker.map = self.googleMapView
let spotObje:Spot = Spot()
spotObje.location = marker.position
spotObje.marker = marker
return spotObje
}

最佳答案

已解决已替换

 customeMarker.drawViewHierarchyInRect(customeMarker.bounds, afterScreenUpdates: true)

customeMarker.layer.renderInContext(UIGraphicsGetCurrentContext()!)

引用:drawViewHierarchyInRect:afterScreenUpdates: delays other animations

关于ios - Swift ios 中的自定义谷歌地图标记图标图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38013022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com