在Swift中更改UIProgressView(Bar样式)的高度

时间:2016-12-18 15:27:28

标签: ios swift swift2 height uiprogressview

我在Swift 2.2中创建了一个UIProgressView(条形样式),现在想改变它的高度。其他一些帖子建议使用CGAffineTransformScale来更改高度。但是,出于某种原因,这种方法似乎不起作用,因为它对UIProgressView的高度没有任何影响。

您将在下面找到我的代码:

let progressBar = UIProgressView(progressViewStyle: .Bar)
progressBar.progress = 0.5
progressBar.translatesAutoresizingMaskIntoConstraints = false
progressBar.transform = CGAffineTransformScale(progressBar.transform, 1, 20)
self.navigationItem.titleView = progressBar

感谢您的帮助,非常感谢!

1 个答案:

答案 0 :(得分:5)

您可以继承login_url = "https://www.facebook.com/login.php?login_attempt=1&lwv=110" glovar.webdriver_browser = webdriver.Chrome() glovar.webdriver_browser.get(login_url) # user credentials user = glovar.webdriver_browser.find_element_by_css_selector("#email") user.send_keys('********@gmail.com') password = glovar.webdriver_browser.find_element_by_css_selector("#pass") password.send_keys('********') login = glovar.webdriver_browser.find_element_by_css_selector("#loginbutton") login.click() glovar.webdriver_browser.get("********") html_user_page = glovar.webdriver_browser.page_source html_file = open(os.path.join(file_directory,type+"_"+user_addr_name+".html"),"w",encoding='utf-8') html_file.write(html_user_page) html_file.close() ,并添加UIProgressView属性:

结果:

  

enter image description here

height

import UIKit class CustomProgressView: UIProgressView { var height:CGFloat = 1.0 // Do not change this default value, // this will create a bug where your progressview wont work for the first x amount of pixel. // x being the value you put here. override func sizeThatFits(_ size: CGSize) -> CGSize { let size:CGSize = CGSize.init(width: self.frame.size.width, height: height) return size } } 中,您首先vc,然后设置customProgressvView

height