BLKFlexibleHeightBar icon indicating copy to clipboard operation
BLKFlexibleHeightBar copied to clipboard

does not work with swift ?

Open gantoday opened this issue 8 years ago • 3 comments

I have tested BLKFlexibleHeightBar in my project, but it just show no effect. And i could not find the reason. Could anyone help me? Many thanks!!

my test project repo: https://github.com/gantoday/BLKFlexibleHeightBar-test

my viewController:

import UIKit
import BLKFlexibleHeightBar


class HomeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let myBar = BLKFlexibleHeightBar(frame: CGRectMake(0.0, 0.0, self.view.frame.size.width, 100.0))
        myBar.minimumBarHeight = 20
        myBar.backgroundColor = UIColor.RedColor()

        myBar.behaviorDefiner = SquareCashStyleBehaviorDefiner()
        myBar.behaviorDefiner.addSnappingPositionProgress(0.0, forProgressRangeStart: 0.0, end: 0.5)
        myBar.behaviorDefiner.addSnappingPositionProgress(1.0, forProgressRangeStart: 0.5, end: 1.0)

        self.tableView.delegate = myBar.behaviorDefiner as? UITableViewDelegate

        self.view.addSubview(myBar)

        self.tableView.contentInset = UIEdgeInsetsMake(myBar.maximumBarHeight, 0.0, 0.0, 0.0);

        let label = UILabel();
        label.text = "hello word"
        label.font = UIFont.systemFontOfSize(25.0)
        label.textColor = UIColor.whiteColor()
        label.sizeToFit()
        myBar.addSubview(label)

        let initialLayoutAttributes = BLKFlexibleHeightBarSubviewLayoutAttributes()
        initialLayoutAttributes.size = label.frame.size
        initialLayoutAttributes.center = CGPointMake(CGRectGetMidX(myBar.bounds), CGRectGetMidY(myBar.bounds) + 10.0)
        label.addLayoutAttributes(initialLayoutAttributes, forProgress: 0.0)


        let finalLayoutAttributes = BLKFlexibleHeightBarSubviewLayoutAttributes(existingLayoutAttributes: initialLayoutAttributes)
        finalLayoutAttributes.alpha = 0.0
        let translation = CGAffineTransformMakeTranslation(0.0, -30.0)
        let scale = CGAffineTransformMakeScale(0.2, 0.2)
        finalLayoutAttributes.transform = CGAffineTransformConcat(scale, translation)
        label.addLayoutAttributes(finalLayoutAttributes, forProgress: 1.0)

    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 30
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 

        return cell

    }

}

gantoday avatar Nov 07 '15 06:11 gantoday