create tag label in swift in swift

To create a tag label in Swift, you can use a UILabel and customize it to look like a tag. Here's an example of how to create a custom tag label:

main.swift
// Create a UILabel
let tagLabel = UILabel()

// Set text
tagLabel.text = "My Tag"

// Set background color
tagLabel.backgroundColor = UIColor(red: 0.94, green: 0.94, blue: 0.94, alpha: 1.00)

// Set corner radius
tagLabel.layer.cornerRadius = 5

// Set font size
tagLabel.font = UIFont.systemFont(ofSize: 14)

// Set padding
tagLabel.contentInset = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)

// Set text color
tagLabel.textColor = UIColor(red: 0.31, green: 0.31, blue: 0.31, alpha: 1.00)

// Set alignment
tagLabel.textAlignment = .center

// Add to view
view.addSubview(tagLabel)
593 chars
27 lines

You can adjust the label's properties to fit your specific needs and design.

gistlibby LogSnag