Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Measuring string width in iOS7

$
0
0

Since NSString StringSize is deprecated in iOS7 and replaced with GetSizeUsingAttributes, I am trying to use the new method. I've seen a couple of posts about this, but haven't had any luck actually getting it to work. Whenever the code executes I get a [...MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFString sizeWithAttributes:]: unrecognized selector sent to instance...]

I'm not sure where the problem is. Here is the code I am using that was modified from some other examples:

NSString nsString = new NSString(column.label);
UIStringAttributes attribs = new UIStringAttributes { Font = UIFont.BoldSystemFontOfSize (15f) };
SizeF headerSize = nsString.GetSizeUsingAttributes(attribs);

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>