-1
我下載了這個項目:https://github.com/YannickSteph/EasyPopup 在它的價值defaultContentView聲明。我無法找到它在哪裏宣佈請幫助!值defaultContentView沒有找到
我下載了這個項目:https://github.com/YannickSteph/EasyPopup 在它的價值defaultContentView聲明。我無法找到它在哪裏宣佈請幫助!值defaultContentView沒有找到
它在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
}
是的,我知道,但defaultContentView,但它之前被稱爲它被稱爲其他?它可以創建不在ViewController? –
我不認爲你明白...'defaultContentView'是一個_function_,它返回一個'UIView'。這不是一個在任何地方聲明的變量。例如,在這一行中,'let contentView = self.defaultContentView ...'指定'contentView'作爲defaultContentView()的返回值。 – random