私は、スクロールビューで垂直方向に配置したい要素がいくつかあります。私はUILabel、UITextView、UIImageView、別のUITextView、別のUITextViewが続いています(scrollViewではヘッダー、イントロ段落、イメージ、本文段落、結論段落が必要です)。ページごとに異なる辞書や画像があるので、これらの要素のサイズをハードコードしてください。どのようにして各ビュー要素のフレームのCGRect浮動小数点サイズを適切に見つけることができますか?特にY値に問題があります。 !これは私が持っているコードです:。scrollviewのコンテンツのCGRectフレームサイジングに問題があるXcode
はstartingY =(?self.navigationControllerを.navigationBar.frame.height)聞かせて+ UIApplication.sharedApplication()statusBarFrame.size.height
//Position subViews on screen.
self.categoryTitle.frame = CGRectMake(0, startingY, self.view.bounds.width, 50)
let secondY = startingY + 50
self.categoryIntro.frame = CGRectMake(0, secondY, self.view.bounds.width, secondY + self.categoryIntro.contentSize.height)
let thirdY = secondY + self.categoryIntro.contentSize.height
self.imageView.frame = CGRectMake(0, thirdY, self.view.bounds.width, thirdY + image.size.height)
let fourthY = thirdY + image.size.height
self.categoryParagraph.frame = CGRectMake(0, fourthY, self.view.bounds.width, fourthY + self.categoryParagraph.contentSize.height)
let fifthY = fourthY + self.categoryParagraph.contentSize.height
self.categoryConclusion.frame = CGRectMake(0, fifthY, self.view.bounds.width, fifthY + self.categoryConclusion.contentSize.height)
ありがとうございます!