我有一個滾動視圖,可以容納我從網上下載的一些圖像。我將這些圖像添加到滾動視圖中,但無法在它們之間添加黑色空間。他們在一個垂直滾動不水平。我一直在考慮嘗試添加空間,但無法弄清楚如何去做。任何幫助,將不勝感激。 這是我到目前爲止;在圖像視圖中的圖像之間添加黑色空格
private func loadImages() {
myImages = 0;
ImageManager.sharedInstance.getAllImagesFromServer({
promotions in
for (_,promotion) in promotions {
Utility.log(self.dynamicType, msg: promotion.picture, function: "viewDidLoad")
self.downloadImage(NSURL(string: promotion.picture)!)
}},
onFail: { error_code, detail in Utility.log(self.dynamicType, msg: "Get All Iamges Fail, error_code: \(error_code), detail: \(detail)",
function: "viewDidLoad")})
}
func getMyImage(url: NSURL){
getDataFromUrl(url) { (data, response, error) in
dispatch_async(dispatch_get_main_queue()) {() -> Void in
guard let data = data where error == nil else { return }
print(response?.suggestedFilename ?? "")
let imageView = UIImageView(image: UIImage(data: data));
imageView.frame = CGRect(x: 0,
y: Int(self.myImages * 200), width: Int(self.myScrollView.frame.size.width), height: 200)
self.myScrollView.addSubview(imageView)
self.myImages = self.myImages + 1;
self.myScrollView.contentSize = CGSizeMake(self.myScrollView.frame.size.width,
CGFloat(self.myImages * 200));
}
}
}
只需增加每個幀的「y」值。 – rmaddy