많은 노력이 보이지 않으므로 대답하지 않으려 고합니다.하지만 여기 있습니다.
xib을 만들고 설정합니다. UIView에서 상속하는 클래스 만들기
클래스를보기에 추가하십시오.
는지도/주석 처리의 ViewController로 파일 소유자를 추가합니다.
여기에 추가 할 수있는 모든 항목을 설정하십시오. 아웃렛을 사용자가 만든 View 클래스에 연결하십시오. 그런 다음 파일 소유자로 지정한 파일에서 :
//create view in code from xib
let annotation = Bundle.main.loadNibNamed("XibFileName", owner: self, options: nil)!.first as? AnnotationClassName
//setup view
annotation.randomLabelOrPropertyOrDelegate = theValueYouWantToAssignItToSetupTheView
//assign the view
viewForAnnotation = annotation
마지막으로 고려해야 할 것은 주석 크기입니다. imageView를 Xib의 기본보기의 가장자리로 제한하면 이미지의 크기와 상관없이 주석이 적용됩니다. 다른 옵션은 xib 파일의 제약 조건이 주어진 프레임을 가질 수 있어야하지만 프레임을 직접 설정하는 것입니다. 이것은 이렇게 할 것입니다
annotation.frame = CGRect(x: 0, y: 0, width: desiredWidth, height: desiredHeight)