2016-08-30 7 views

答えて

0

ViewController行250-272で宣言されています。 defaultContentViewは関数です。

/** 
    Create content view 

    :param: width  CGFloat 
    :param: height CGFloat 
    :param: imageName String 

    :returns: UIView 
    */ 
    func defaultContentView(width:CGFloat,height:CGFloat, imageName:String, offSet:CGFloat = -200) -> UIView { 
     var contentView = UIView(frame: CGRectMake(0, 0, width, height)) 


     // create the title label 
     let titleLabel = UILabel(frame: CGRectMake(0, 0, width, 30)) 
     titleLabel.text = "Example blabla, Cool popup !" 
     titleLabel.textAlignment = .Center 
     titleLabel.font = UIFont.systemFontOfSize(17) 
     contentView.addSubview(titleLabel) 

     contentView.setTranslatesAutoresizingMaskIntoConstraints(false) 


     titleLabel.autoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | 
      UIViewAutoresizing.FlexibleRightMargin | 
      UIViewAutoresizing.FlexibleTopMargin | 
      UIViewAutoresizing.FlexibleBottomMargin 
     titleLabel.center = CGPointMake(view.bounds.midX, view.bounds.midY + offSet) 
     self.defaultImage(contentView,name: imageName) 

     return contentView 
    } 
+0

私はdefaultContentViewを知っていますが、他の場所で宣言される前に呼び出されていますか?それはViewControllerではなく作成できますか? –

+0

私はあなたが理解しているとは思わない... 'defaultContentView'は' UIView'を返す_function_です。どこでも宣言されている変数ではありません。例えば、この行では 'let contentView = self.defaultContentView ...'を 'defaultContentView()'の戻り値に 'contentView'を代入します。 – random

関連する問題