0
我轉換自定義視圖加載從xib到UIImage
顯示爲標記icon.it完成,但問題是,當這樣做for循環顯示100個標記UI卡住是因爲加載xib自定義視圖?自定義谷歌地圖標記圖標圖像在swift ios
是函數調用在循環
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
}
做一個回地面線程 – Shubhank
在後臺線程中嘗試過,但出現錯誤此應用程序正在修改後臺線程的自動佈局引擎,這可能導致引擎損壞和奇怪的崩潰。這將在未來的版本中引發異常。 –
請在單獨的http://gist.github.com鏈接中顯示更新的代碼 – Shubhank