Calculating UILabel Text Size

All of the [NSString sizeWithFont…] methods are deprecated in iOS 7. Use this instead. CGRect labelRect = [text boundingRectWithSize:labelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:14] } context:nil]; Also see https://developer.apple.com/documentation/foundation/nsstring/1619914-sizewithfont. UPDATE – example of boundingRectWithSize output Per your comment I did a simple test. The code and output is below. // code to generate a … Read more

How does clipsToBounds work?

If my superview is a box measuring 10 units on each side, and my subview is 20 units wide, with clipsToBounds set to YES, I’ll only see the part of the subview that fits within the bounds of the superview. Otherwise, if clipsToBounds is set to NO, I’ll see the entire subview, even the parts … Read more

JsPDF – Not allowed to navigate top frame to data URL

This works well now that chrome has removed top frame navigation. Only downloading the pdf in chrome gives problem. Download works in well in firefox tho. var string = doc.output(‘datauristring’); var iframe = “<iframe width=”100%” height=”100%” src=”” + string + “”></iframe>” var x = window.open(); x.document.open(); x.document.write(iframe); x.document.close();

How to render an openGL frame in C++ builder?

easy, just use TForm::Handle as window handle … Here some ancient example of mine in BCB5 ported to BDS2006: //————————————————————————— #include <vcl.h> #pragma hdrstop #include “Unit1.h” #include <gl/gl.h> #include <gl/glu.h> //————————————————————————— #pragma package(smart_init) #pragma resource “*.dfm” TForm1 *Form1; //————————————————————————— int TForm1::ogl_init() { if (ogl_inicialized) return 1; hdc = GetDC(Form1->Handle); // get device context PIXELFORMATDESCRIPTOR pfd; … Read more

the images are not loading

I’m sorry to say this, but there are simply so many things wrong with your code… Lets start with: DON’T override any of the paint methods of a top level container. To start with, none of the top level containers are double buffered. Use light weight components instead of heavy weight components (use JFrame instead … Read more

Can I use setFrame and autolayout on the same view?

Yes, this can be done. If you set a view’s translatesAutoresizingMaskIntoConstraints = YES, then calls to setFrame: are automatically translated at runtime into layout constraints based on the view’s current autoresizingMask. This lets you mix frame-based layout with constraint-based layout. For instance you could use Auto Layout to define the layout of all of the … Read more

Html code as IFRAME source rather than a URL

You can do this with a data URL. This includes the entire document in a single string of HTML. For example, the following HTML: <html><body>foo</body></html> can be encoded as this: data:text/html;charset=utf-8,%3Chtml%3E%3Cbody%3Efoo%3C/body%3E%3C/html%3E and then set as the src attribute of the iframe. Example. Edit: The other alternative is to do this with Javascript. This is almost … Read more

Adjust UILabel height to text

I’ve just put this in a playground and it works for me. Updated for Swift 4.0 import UIKit func heightForView(text:String, font:UIFont, width:CGFloat) -> CGFloat{ let label:UILabel = UILabel(frame: CGRectMake(0, 0, width, CGFloat.greatestFiniteMagnitude)) label.numberOfLines = 0 label.lineBreakMode = NSLineBreakMode.byWordWrapping label.font = font label.text = text label.sizeToFit() return label.frame.height } let font = UIFont(name: “Helvetica”, size: 20.0) … Read more