Post

Replies

Boosts

Views

Activity

Reply to Get size of subviews or/and UI elements through code
// Outlets @IBOutlet weak var topView: UIStackView! //view did load  override func viewDidLoad() {         super.viewDidLoad() let topLayer = CAGradientLayer()         topLayer.frame = topView.frame         topLayer.colors = [UIColor(red: 0.13, green: 0.22, blue: 0.35, alpha: 0.80).cgColor , UIColor(red: 0.18, green: 0.26, blue: 0.39, alpha: 1.00).cgColor]         topLayer.locations = [0.0, 1.0]         topView.layer.insertSublayer(topLayer, at: 0) } If I use this code and run it on the simulator the layer is not as big as the view. Unfortunately I can not attach a picture to show you how it looks. I want the layer always as big as the view. Maybe it is clearer now ?
May ’21
Reply to Get size of subviews or/and UI elements through code
Yes that should happen, but if I set the topLayer.frame = topView.frame the layer is not shown correctly. Depending which device I choose in the simulator the layer is either shown too big or too small. I am looking for a solution, where the layer is always as big as the view. In my example the topView is a view where a button and a caption is placed. Depending on the device the height and width are changing, so I want that the size of the layer is changing too. I hope my problem is understandable.
May ’21
Reply to insert Json file into core Data
Thank you for your answer, but this is not quite that what I was looking for, yesterday I was a little bit confused what to do next, now I have a plan that do not work. I want this JSON file (as described above), convert into a dictionary. With this dictionary I'd like to create Arrays, which I insert into CoreData. Inserting into CoreData ist working. I am struggling with convert the JSON file into a Dictionary and extract values from this Dictionary to create an Array. Maybe there is a simpler way to do it?
Apr ’21
Reply to CAGradientLayer covers Label in Table View Cell
I changed the code like you suggested, but the layer still covers the text. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {         let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)         if filtered {             cell.textLabel?.text = filteredData[indexPath.row]         }         else{             cell.textLabel?.text = collectionEintraege[indexPath.row]         }         let layer = CAGradientLayer()         layer.frame = cell.bounds.insetBy(dx: 4, dy: 7)         layer.colors = [UIColor(red: 0.19, green: 0.22, blue: 0.25, alpha: 1.00).cgColor, UIColor(red: 0.25, green: 0.26, blue: 0.28, alpha: 1.00).cgColor]         cell.contentView.layer.addSublayer(layer)         cell.layer.borderWidth = 1         cell.layer.borderColor = UIColor.white.cgColor         cell.textLabel?.textColor = UIColor.white         cell.textLabel?.font = UIFont(name: "Helvetica", size: 25.0)         return cell     } Do you have an idea what else I could try?
Mar ’21
Reply to CAGradientLayer covers Label in Table View Cell
This is the code, where I add the sublayer func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {         let layer = CAGradientLayer()         layer.frame = CGRect(x: 0, y: 0, width: 5000, height: 70)         layer.colors = [UIColor(red: 0.19, green: 0.22, blue: 0.25, alpha: 1.00).cgColor, UIColor(red: 0.25, green: 0.26, blue: 0.28, alpha: 1.00).cgColor]         cell.layer.addSublayer(layer)     } This is the code, where I add the entrie/text Label, the filtered part I need for the search func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {         let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)         if filtered {             cell.textLabel?.text = filteredData[indexPath.row]         }         else{             cell.textLabel?.text = collectionEintraege[indexPath.row]         }         cell.layer.borderWidth = 1         cell.layer.borderColor = UIColor.white.cgColor         cell.textLabel?.textColor = UIColor.white         cell.textLabel?.font = UIFont(name: "Helvetica", size: 25.0)         return cell     }
Mar ’21
Reply to Create a blinking label
I tired this in the viewDidLoad() function, but this does not show me the blinking, instead the View show up, when the for-loop has finished. caption.backgroundColor = UIColor.black 				for _ in 0...2{ 						var bool = false 								if bool{ 										caption.backgroundColor = UIColor.black 										bool = false 								} 								else { 										caption.backgroundColor = UIColor.systemRed 										bool = true 						} 						sleep(1) 				}
Jan ’21