Home > Software engineering >  how can I make that label go down a line between every string
how can I make that label go down a line between every string

Time:01-02

I have this array of string I want it inside the label so that every string has line

"method": [
    "Bring a large frying pan of salted water to the boil over medium-high heat. Add the asparagus and cook for 2-3 minutes or until bright green and tender crisp. Use tongs to transfer the asparagus to a plate. Cover to keep warm.",
    "Add the vinegar to the water in pan. Reduce heat to medium-low. Crack 1 egg into a small bowl. Use a spoon to stir the water to make a whirlpool. Carefully pour the egg into the centre of the whirlpool. Cook for 4 minutes for a soft yolk or until cooked to your liking. Use a slotted spoon to transfer to a plate. Cover with foil to keep warm. Repeat with remaining eggs.",
    "Divide the asparagus among serving plates. Top with an egg. Season with salt and pepper. Top with parmesan to serve."
]

I want it inside the label so that every string has line

CodePudding user response:

You can try something like this:

let arrayStr = [ "Bring a large frying pan of salted water to the boil over medium-high heat. Add the asparagus and cook for 2-3 minutes or until bright green and tender crisp. Use tongs to transfer the asparagus to a plate. Cover to keep warm.", "Add the vinegar to the water in pan. Reduce heat to medium-low. Crack 1 egg into a small bowl. Use a spoon to stir the water to make a whirlpool. Carefully pour the egg into the centre of the whirlpool. Cook for 4 minutes for a soft yolk or until cooked to your liking. Use a slotted spoon to transfer to a plate. Cover with foil to keep warm. Repeat with remaining eggs.", "Divide the asparagus among serving plates. Top with an egg. Season with salt and pepper. Top with parmesan to serve." ]

SwiftUI

Text(arrayStr.joined(separator: "\n\n"))

Storyboard

label.text = arrayStr.joined(separator: "\n\n")
  • Related