1

Created a UILabel

            lbl_Username = new UILabel {
                Text = "Username",
                Font = UIFont.FromName (DrugHub.Constants.K_HELVETIC_BOLD, KFontSize12),
            };
// Frame the label
            lbl_Username.Frame = new RectangleF (40, 20, 100, 12);
View.addSubView(lbw_Username.Frame);

How to set frame width size "auto". Size to fit on text content.

currently using Username for label and set label.width = 100,

label.width need to set automatically adjust according to content inside the Label.Text.

@All Thanks In advance.

kiran
  • 4,285
  • 7
  • 53
  • 98
  • 1
    After posting question:: i figure out the answer. lbl_Username.AttributedText.Size.Width. – kiran Jul 26 '14 at 09:35

1 Answers1

1
CGSize size = [string sizeWithAttributes:
                       @{NSFontAttributeName:
                         [UIFont systemFontOfSize:17.0f]}];

Replacement for deprecated sizeWithFont: in iOS 7?

Dynamically resize label in iOS 7

Dynamically getting height of UILabel according to Text return different Value for iOS 7.0 and iOS 6.1

this link help you.

Community
  • 1
  • 1
Daxesh Nagar
  • 1,405
  • 14
  • 22