I have the following code that creates buttons based on the fetched data. After buttons are created they get added to a scrollview. And they should display horizontally.
I can confirm that there is data but it shows weird things in simulator (see attached screenshot). What is wrong in my implementation?
override func viewDidLoad() {
    super.viewDidLoad()
    fetchRecipeCategory()
    for var i = 0; i < self.category.count; i++ {
        let frame1 = CGRect(x: 20, y: 20 + (index * 45), width: 45, height: 45 )
        let button = UIButton(frame: frame1)
        button.setTitle("\(category[i].name)", forState: .Normal)
        button.backgroundColor = UIColor.blackColor()
        self.categoryScrollView.addSubview(button)
    }
    print(category[0].name)
}

 
    