如何使用CosmicMinds材质库减少材质Textfield中动画占位符文本的空间?

时间:2017-06-02 11:20:10

标签: swift3 ios10 cosmicmind

我正在为我的一个项目使用CosmicMinds Material库。我正面临悬停文本的一个问题。我想减少我无法弄清楚的空间。Attached Image

我的SampleCode:

import UIKit


class FirstViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {

    @IBOutlet weak var tableView: UITableView!

    var tbCount = 0

    var myMp3s = [Mp3]()

    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.dataSource = self
        tableView.delegate = self

        let url = URL(string: "http://example.php")


        URLSession.shared.dataTask(with:url!, completionHandler: {(data, response, error) in
            guard let data = data, error == nil else { return }

            do {
                let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String:Any]
                let posts = json["server_response"] as? [[String: Any]] ?? []


                for i in posts {

                    print(i["id"]!)

                    let mp3 = Mp3(id: i["id"] as! String, category: i["kategori"] as! String)

                    self.myMp3s.append(mp3)


                }

                self.tableView.reloadData()


                print("counte", self.myMp3s.count)

            } catch let error as NSError {
                print(error)
            }
        }).resume()

    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return myMp3s.count

    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell  = UITableViewCell()

        cell.textLabel?.textAlignment = .center

        cell.textLabel?.text = self.myMp3s[indexPath.row].category

        return cell
    }


    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(myMp3s[indexPath.row].category)
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



}

1 个答案:

答案 0 :(得分:1)

您是否尝试过placeholderVerticalOffset属性?