2016-07-07 4 views
0

다음과 같이 func를 호출하려고합니다. loadImage()에 무엇을 써야 호출 할 때마다 다른 이미지 이름을 입력 할 수 있습니까?변수 이름으로 이미지 이름 (Swift)

많은 감사

imageName는 매개 변수의 이름이고 String이 유형입니다
func loadImage(????){ 

     self.Picture.image = UIImage (named: "Ch1-4 new.jpg") 

       UIView.animateWithDuration(3.0, 
            delay: 0.0, 
            options: [], 
            animations : { 

            let message = "Picture.mp3" 
            let triggerTime = (Int64(NSEC_PER_SEC) * 1) 
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, triggerTime), dispatch_get_main_queue(), {() -> Void in 
             self.playMessageOpening(message) 
            }) 
            self.Picture.hidden=false 
            self.Picture.alpha=0.0; 
            self.Picture.alpha=1.0; 

      }, 
            completion: { finished in 
            print("Picutre done") 


     }) 
    } 

답변

2
func loadImage(imageName: String) { 
    self.Picture.image = UIImage (named: imageName) 

    ... 
} 

. the Apple docs의 함수 선언에 대해 자세히 설명합니다.