cgrectmake

Change a UIView Frame

眉间皱痕 提交于 2020-01-21 20:10:33
问题 I have set a UIView in my storyboard and make it an outlet. @property (nonatomic, weak) IBOutlet UIView *testView; In the - (void)viewDidLoad method, I want to change its frame like this CGRect frame = self.testView.frame; frame.size.height = 2; self.testView.frame = frame; But it does not work. Anybody can tell me why? 回答1: You might enabled the autolayout in your project , if so the setFrame straightly won't work . Check here for more info Solution : Disable the autolayout, if you don't

Put shadow to a rectangle (drawRect:(CGRect)rect)

醉酒当歌 提交于 2020-01-06 08:23:45
问题 I did a rectangle with this code and it works: - (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddRect(context, CGRectMake(60, 60, 100, 1)); CGContextStrokePath(context); } But now i want to put a shadow, I tried with this: NSShadow* theShadow = [[NSShadow alloc] init]; [theShadow setShadowOffset:NSMakeSize(10.0, -10.0)]; [theShadow setShadowBlurRadius:4.0]; But xcode tell me about NSMakeSize : Sending 'int' to parameter of incompatible type

Put shadow to a rectangle (drawRect:(CGRect)rect)

半城伤御伤魂 提交于 2020-01-06 08:22:06
问题 I did a rectangle with this code and it works: - (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddRect(context, CGRectMake(60, 60, 100, 1)); CGContextStrokePath(context); } But now i want to put a shadow, I tried with this: NSShadow* theShadow = [[NSShadow alloc] init]; [theShadow setShadowOffset:NSMakeSize(10.0, -10.0)]; [theShadow setShadowBlurRadius:4.0]; But xcode tell me about NSMakeSize : Sending 'int' to parameter of incompatible type

UIView Frame Size Didn't Change UIImageView Placed inside it

你离开我真会死。 提交于 2020-01-02 19:30:10
问题 I'm making a picture in a frame and then user can resize the frame size in runtime. For this purpose I've made a custom UIView in my main UIViewController and inside this UIView I've placed 2 UIImageView . In Document Outline Pane of xCode it's hierarchy is: View |--ImageView |--ImageView I'm using this line of code to change size of UIView under different conditions it'll resize accordingly: self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , self.imageObject.frame.origin.y

iOS frame change one property (eg width)

五迷三道 提交于 2019-12-17 23:08:42
问题 This question was originally asked for the objective-c programming language. At the time of writing, swift didn't even exist yet. Question Is it possible to change only one property of a CGRect ? For example: self.frame.size.width = 50; instead of self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 50); of course I understand that self.frame.size.width is read only so I'm wondering how to do this? CSS ANALOGY proceed at your own risk for those of you who

Programmatically setting content to fill screen between tab bar and nav controller

点点圈 提交于 2019-12-11 15:23:58
问题 I have a UIwebview that I want to fill the screen between the navigation bar at the top and the tab bar at the bottom. My web view is being defined programmatically and I was initializing it with a frame as below. I have been able to get the desired behavior by hard coding in some values, but I have seen that this does not work across all devices. Specifically, it seems that different OS's might consider (0,0) as different points on the screen (the top left corner of the screen for some, and

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'

我们两清 提交于 2019-12-11 14:54:50
问题 The problem started with the XCode 10.2.x as I guess While it was working fine with the XCode 10.1 The crash point is " pdfView.frame = self.view.frame " from below code: import UIKit import PDFKit class ViewController: UIViewController { var pdfView = PDFView() override func viewDidLoad() { super.viewDidLoad() // Prepare document to show let url = Bundle.main.url(forResource: "sample", withExtension: "pdf") let pdfDocument = PDFDocument(url: url!) // PDFView pdfView = PDFView() pdfView.frame

How to get the exact point of objects in swift?

微笑、不失礼 提交于 2019-12-08 10:43:07
问题 I'm using a UIProgressView and want to stick a image subview to the progress % as in the image below: I want to get the co-ordinate of the progress tint and red subview as in the figure to " stick " with the progress tint, whatever the progress will be.. 回答1: You can start by vertically centering the image view with the progress view using constraints or programmatically like below. imageView.center.y = progressView.center.y Then where ever you are updating the progress, after you can

UIView Frame Size Didn't Change UIImageView Placed inside it

北战南征 提交于 2019-12-06 07:25:13
I'm making a picture in a frame and then user can resize the frame size in runtime. For this purpose I've made a custom UIView in my main UIViewController and inside this UIView I've placed 2 UIImageView . In Document Outline Pane of xCode it's hierarchy is: View |--ImageView |--ImageView I'm using this line of code to change size of UIView under different conditions it'll resize accordingly: self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , self.imageObject.frame.origin.y, 200, 200); imageObject is my UIView . When I run it the size of the UIView changes but UIImageView

Make view cover full screen using CGRectMake

自古美人都是妖i 提交于 2019-12-04 04:04:35
问题 I'm creating a view (using card.io), and I want the view to cover the full screen. Its only covering about 2/3rds of the screen atm. Heres the code: CardIOView *cardIOView = [[CardIOView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)]; Here is an example 回答1: Dave from card.io here. When you create a CardIOView , its frame will take on whatever size you set. However, the camera view within the (transparent) CardIOView will have the standard iOS