久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Swift iOS以編程方式在導(dǎo)航欄下方設(shè)置滾動(dòng)視圖約

Swift iOS Set scrollView constraint below navigation bar programmatically(Swift iOS以編程方式在導(dǎo)航欄下方設(shè)置滾動(dòng)視圖約束)
本文介紹了Swift iOS以編程方式在導(dǎo)航欄下方設(shè)置滾動(dòng)視圖約束的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我的 UIViewController 嵌入在導(dǎo)航控制器中.我以編程方式添加導(dǎo)航按鈕,現(xiàn)在嘗試在此導(dǎo)航欄下方添加一個(gè)滾動(dòng)視圖.我遇到的問(wèn)題是,這是填充全幀大小并位于導(dǎo)航欄下方.

My UIViewController is embedded in a navigation controller. I programmatically add the navigation buttons and now trying to add a scrollView below this navigation bar. The problem I'm having is this is filling the full frame size and going under the navigation bar.

如何以編程方式設(shè)置此滾動(dòng)視圖的約束?

How do I programmatically set constraints of this scrollview?

var scrollView: UIScrollView!
var containerView = UIView()

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.title = "Filters"
    // add some buttons on the navigation

    self.scrollView = UIScrollView()
    self.scrollView.backgroundColor = UIColor.grayColor()
    self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height)

    containerView = UIView()

    scrollView.addSubview(containerView)
    view.addSubview(scrollView)

    let label = UILabel(frame: CGRectMake(0, 0, 100, 21))
    label.text = "my label"
    containerView.addSubview(label)
}

推薦答案

雖然Clafou的回答肯定是對(duì)的,但是如果你不需要透明度,想在導(dǎo)航欄下啟動(dòng),真正正確的方法是改變ViewController的行為所以它適合內(nèi)容.為此,您有兩種選擇:

While Clafou's answer is certainly correct, if you don't need transparency and want to start under navigation bar, the really proper way is to change behavior of the ViewController so it fits the content properly. To do that, you have two options:

1) 假設(shè)您有 Storyboard,轉(zhuǎn)到 ViewController Attributes Inspector 并禁用Under top bars"

1) Assuming you have Storyboard, go to ViewController Attributes Inspector and disable "Under top bars"

2) 假設(shè)您是通過(guò)代碼實(shí)現(xiàn)的一切,您將需要查找以下屬性 - edgesForExtendedLayoutextendedLayoutIncludesOpaqueBars.已經(jīng)有 很好的答案 所以我不會(huì)在這里覆蓋它.

2) Assuming you are everything through code, you will want to look for following properties - edgesForExtendedLayout, and extendedLayoutIncludesOpaqueBars. There is great answer for that already on SO so I won't cover it here.

希望對(duì)你有幫助!

這篇關(guān)于Swift iOS以編程方式在導(dǎo)航欄下方設(shè)置滾動(dòng)視圖約束的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設(shè)置滾動(dòng)視圖內(nèi)容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動(dòng)滾動(dòng))
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運(yùn)行時(shí),使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會(huì)導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 日韩精品在线播放 | 国产中文一区二区三区 | 国产精品久久久一区二区三区 | 欧美一区免费 | 成人深夜福利 | 国产午夜精品视频 | av国产精品 | 日韩精品久久一区 | 日日操日日舔 | 成人黄色av| 国产精品视频免费看 | 日韩欧美1区2区 | 狠狠爱综合 | 亚洲网一区 | 午夜影院在线播放 | 蜜桃黄网 | 日本精品久久久久 | 国产成人免费一区二区60岁 | 欧美日韩免费在线 | 久干网| 欧美自拍第一页 | 成人亚洲精品 | 久久久久久久久久毛片 | 国产蜜臀| 国产一区二区三区久久久久久久久 | 亚洲视频中文字幕 | 51ⅴ精品国产91久久久久久 | 国产激情第一页 | 精品国产乱码久久久久久88av | 天天操天天天干 | 亚洲精品一区二区冲田杏梨 | 日韩免费一区 | 亚洲欧美在线一区 | 国产69久久精品成人看动漫 | 精品视频一区二区 | 免费三级黄| 欧美午夜一区二区三区免费大片 | 亚洲精品一区二区三区中文字幕 | 亚洲欧美在线一区 | 国内精品久久久久久久 | 天天干,夜夜操 |