কম্পিউটার টিউটোরিয়াল

আইওএস অ্যাপে TextView-এ একাধিক স্টাইল (Multiple Styles) ব্যবহার করার পদ্ধতি


UITextView-এ একাধিক স্টাইল (রঙ, ফন্ট সাইজ) ব্যবহার করতে NSAttributedString ব্যবহার করুন।

let tx = UITextView()
tx.isScrollEnabled = true
tx.isUserInteractionEnabled = true
tx.frame = CGRect(x: 10, y: 25, width: self.view.frame.width, height: 100)

let attributeOne: [NSAttributedString.Key: Any] = [
    .font: UIFont.systemFont(ofSize: 16),
    .foregroundColor: UIColor.blue
]
let attributeTwo: [NSAttributedString.Key: Any] = [
    .font: UIFont.systemFont(ofSize: 20),
    .foregroundColor: UIColor.red
]

let string = NSAttributedString(string: "Text for first Attribute", attributes: attributeOne)
let string2 = NSAttributedString(string: "Text for first Attribute", attributes: attributeTwo)

let finalAttributedString = NSMutableAttributedString()
finalAttributedString.append(string)
finalAttributedString.append(string2)
tx.attributedText = finalAttributedString
self.view.addSubview(tx)

ফলাফল —

আইওএস অ্যাপে TextView-এ একাধিক স্টাইল (Multiple Styles) ব্যবহার করার পদ্ধতি


  1. অ্যান্ড্রয়েড অ্যাপে TextToSpeech তৈরি করার পদ্ধতি

  2. Facebook-এ Android অ্যাপ তৈরি করার পদ্ধতি

  3. iOS 14-এ App Library কীভাবে ব্যবহার করবেন

  4. iOS-এ একাধিক PDF ফাইল একসাথে জোড়া করার উপায়