cgrect

Crop area different than Selected Area in iOS?

心已入冬 提交于 2019-12-21 05:02:09
问题 Here is link on github https://github.com/spennyf/cropVid/tree/master to try it out your self and see what I am talking about it would take 1 minute to test. Thanks! I am taking a video with a square to show what part of vid will be cropped. Like this: Right now I am doing this of a piece of paper with 4 lines in the square, and half a line difference on top and bottom. And then I crop the video using code I will post, but then when I display the video I see this (Ignore background and green

How to set UIView size to match parent without constraints programmatically

混江龙づ霸主 提交于 2019-12-21 03:53:14
问题 The problem sounds easy but it is making me crazy. I've created a white view in IB that's called iBag and by constraints it's size depends on screen size. Now I want create a new UIView programmatically and add as subview to iBag with same size and position by this code let newView = UIView() newView.frame = (frame: CGRect(x: 0, y: 0, width: iBag.frame.width, height: iBag.frame.height)) newView.backgroundColor = UIColor.redColor() iBag.addSubview(newView) I also tried bounds but that didn't

Get position of UIView in respect to its superview's superview

喜欢而已 提交于 2019-12-18 09:58:47
问题 I have a UIView, in which I have arranged UIButtons. I want to find the positions of those UIButtons. I am aware that buttons.frame will give me the positions, but it will give me positions only with respect to its immediate superview. Is there is any way we can find the positions of those buttons, withe respect to UIButtons superview's superview? For instance, suppose there is UIView named "firstView". Then, I have another UIView, "secondView". This "SecondView" is a subview of "firstView".

How to get coordinates (CGRect) for the selected text in UIWebView?

≯℡__Kan透↙ 提交于 2019-12-17 23:27:48
问题 I have simple UIWebView with loaded html. I want to show the PopoverView pointed to the selected text. I can get the menuFrame of the UIMenuController and use its rect, but the result isn't as accurate at the corners of the screen as I need. I can calculate the screen size and get menuFrame rect and then I can suppose where the selection may be found, but I want exactly know where is the selected text. Is it generally possible? 回答1: You can use the javascript function getBoundingClientRect()

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

Organize and adjust the UILabel position per devices - Swift 3

旧街凉风 提交于 2019-12-13 07:26:56
问题 I have SQLite database file and UILabel, and I set text for label from database on the number of characters after convert String to Characters , and I added extension its name ( length ), its job counts the number of characters. My problem in this picture is : The UILabels are not organized in sizes and positions in per devices I want them to have their positions in the center of X-Axis Questions: 1) How to set the label into center and set spaces right and left of screen for labels (per

Failing make Navigation Bar of an UINavigationController display at the bottom programmatically [duplicate]

瘦欲@ 提交于 2019-12-13 05:30:59
问题 This question already has answers here : How to make the Navigation Bar of an UINavigationController display at the bottom? (4 answers) Closed 5 years ago . i am trying to make Navigation Bar of an UINavigationController display at the bottom. Put this in the viewWillApprear, it can work. But it go back to the top when come back via dismiss modal view from other views. Even this will be called again, it just stay on the top. So odd ! CGRect navBarOldCGRect = self.navigationController

What is the method “backgroundRect(forBounds:)” of UIButton used for?

谁说胖子不能爱 提交于 2019-12-13 03:24:07
问题 I found out that UIButton has a backgroundRect(forBounds:) function, but I can not understand where and how can I use it. I also cannot understand how can I use the contentRect(forBounds:) , titleRect(forContentRect:) and imageRect(forContentRect:) methods. Please, explain me. 回答1: By default, backgroundRect(forBounds:) returns the same value as bounds . However, you can override it in a subclass to prevent drawing over your custom content. From Apple Developer Documentation: The default

CGRectContainsPoint does not work on different views

心已入冬 提交于 2019-12-12 05:46:36
问题 I am making a simple drag drop project. When I use CGRectContainsPoint to drag a view and drop on different view it works. But both of the view should be in a same view. Now let's say I have a view called "A" and it contains two views. One UIView and one UIStackView . If I drag a view inside of Stack View to UIView it does not drop. Simply CGRectContainsPoint does not work for dragging and dropping from different views. Is there any way to solve it? 回答1: As each view has it's own coordinate

Set frame (CGRect) per devices by count of characters - Swift 3

不羁岁月 提交于 2019-12-12 05:28:40
问题 I'm creating label and characters, I want set frame (X, Y and width) of UILabel by characters and Y-axis is constant of all devices, so how can I set center of X-axis and controlling by count of characters, and width (50) gets smaller and bigger per device ?? This my code : func createTarget(id: Int) { listdata = dbHelpr.getDatabase(rowId: id) for data in listdata { let lengthOfChar : CGFloat = data.ans.length let targetSize : CGFloat = self.view.frame.width / 2 var xAxis : CGFloat = self