2016-10-28 5 views
0

포드를 사용하여 코어 플롯 2.2를 설치할 수 있습니다. swift를 사용하여 x 축에 맞춤 라벨을 원했습니다. 그것을 위해 나는 그것은 "선언되지 않은 유형 'CPTMutableAxisLabelSet'사용 '으로 컴파일러 오류를 제공합니다 다음 코드undeclared type 'CPTMutableAxisLabelSet'사용

let axisArray = ["Sun", "Mon", "Tues", "Weds", "Thurs", "Fri", "Sat"] 
      let customLabel: CPTMutableAxisLabelSet = [] 
      let tickLocation: NSArray = [3, 6, 9, 12, 15, 18, 21] 
      var labelLocation: Int = -1 
      for var number in tickLocation { 
       labelLocation += 1 
       let newLabel = CPTAxisLabel.init(text: axisArray[labelLocation], textStyle: x.labelTextStyle) 
       newLabel.tickLocation = number as! NSNumber 
       newLabel.offset = x.labelOffset + x.majorTickLength 
       newLabel.rotation = CGFloat(M_PI/Double(4.0)) 
       customLabel.add(newLabel) 
      } 
      x.axisLabels = NSSet.init(array: (customLabel as AnyObject) as! [Any]) as! Set<CPTAxisLabel> 

작성했습니다. "CPTMutableAxisLabelSet"을 "NSMutableArray"로 바꾸려고하면 응용 프로그램이 충돌합니다. 어느 누구라도 신속하게 맞춤형 라벨을 만드는 방법을 알려줄 수 있습니까?

답변

0

Swift 컬렉션을 사용하는 것이 훨씬 간단합니다.

var customLabels = Set<CPTAxisLabel>() 
// create the custom labels and add them to the set 
x.axisLabels = customLabels 
+0

답변 해 주셔서 감사합니다. – Gyanendra