2016-09-21 16 views
0

방금 ​​swip 2.3 코드를 3.0으로 변환했습니다. 그러나 갑자기 글꼴 유형을 변경하려고하면 UILabel보기에 오류가 표시됩니다. 다음은 오류입니다. 그것은 (name: String, size: CGFloat)-> UIFont is not convertible to (name: String, size: CGFloat)-> UIFont? 글꼴 유형을 변경할 수없는 이유는 무엇입니까? 나는 청소하고 프로젝트를 만들었지 만 같은 오류를 보여줍니다. 여기에 UILabel의 여기UIFont가 변환 할 수 없음 오류

 let placeholder = UILabel() 
     placeholder.bounds = self.tableView.bounds 
     placeholder.textAlignment = .Center 
     placeholder.textColor = UIColor(red: 230.0/255.0, green: 230.0/255.0, blue: 230.0/255.0, alpha: 1.0) 
     placeholder.font = UIFont(name: "Avenir-Light", size: 15.0) 
     placeholder.text = "No Events" 
     self.tableView.backgroundView = placeholder 

당신이 쓰는 시도해야 오류

enter image description here

답변

2
placeholder.font = UIFont(name: "Avenir-Light", size: 15.0) 

입니다 : 자세한 내용은

placeholder.font = UIFont.init(name: "Avenir-Light", size: 15) 

this

+0

감사합니다! 그것은 작동하지만, 왜 UIFont (이름 : "Avenir-Light", 크기 : 15.0)를 쓸 수 없습니까? init()을 작성해야하는 이유는 무엇입니까? –

+1

@ChathurangaSilva - 스위프트에서 사용 가능한 이니셜 라이저 업데이트 문제입니다. –

관련 문제