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

একটি UILabel-এ Bold এবং Non-Bold টেক্সট একসাথে ব্যবহার করার পদ্ধতি


একটি UILabel-এ বোল্ড (Bold) এবং নন-বোল্ড (Regular) টেক্সট একসাথে ব্যবহার করা যায় দুটি পদ্ধতিতে — স্টোরিবোর্ড থেকে বা প্রোগ্রাম্যাটিক্যালি।

পদ্ধতি ১: স্টোরিবোর্ড থেকে এডিট

  • লেবেল সিলেক্ট করুন, Attribute Inspector-এ যান।
  • Text-এ "Plain"-এর বদলে "Attributed" সিলেক্ট করুন।
  • লিখুন: Bold Regular
  • "Bold" শব্দটি সিলেক্ট করুন, রাইট ক্লিক → Font → Bold সিলেক্ট করুন।

পদ্ধতি ২: প্রোগ্রাম্যাটিক্যালি (NSAttributedString)

override func viewDidLoad() {
    super.viewDidLoad()
    let boldAttribute: [NSAttributedString.Key: Any] = [
        .font: UIFont(name: "HelveticaNeue-Bold", size: 18.0)!
    ]
    let regularAttribute: [NSAttributedString.Key: Any] = [
        .font: UIFont(name: "HelveticaNeue-Light", size: 18.0)!
    ]
    let boldText = NSAttributedString(string: "Bold", attributes: boldAttribute)
    let regularText = NSAttributedString(string: " regular", attributes: regularAttribute)
    let newString = NSMutableAttributedString()
    newString.append(boldText)
    newString.append(regularText)
    lbl.attributedText = newString
}

উপরের যেকোনো পদ্ধতি ফলো করলে নিচের ফলাফল मिलবে।

একটি UILabel-এ Bold এবং Non-Bold টেক্সট একসাথে ব্যবহার করার পদ্ধতি


  1. আইফোনে 3D Touch ব্যবহার করার সম্পূর্ণ গাইড

  2. iOS 12-এ iPhone-এর অ্যাক্সেসিবিলিটি ফিচার ব্যবহার করার উপায়

  3. নিরাপদে আইওএস ডাউনগ্রেড: ধাপে ধাপে গাইড

  4. iOS 12 শীঘ্র ইনস্টল করুন: Apple Beta জয়েন করে নতুন ফিচার অ্যাক্সেস করার ধাপে ধাপে গাইড