93 questions
0
votes
1
answer
67
views
Calculate Offset Limit of mask bounds
Hi all I'm trying to set the offset limits so that the image during the dragGesture never exceeds the outlines of the mask...
Thanks to the help of Benzy Neez I obtain a scaleOffset value that I use ...
1
vote
0
answers
55
views
How can I change the size of a UITextField?
I want to change the size of the UITextField programmatically.
Actually what I want to do exactly is this UIAlertView inside I have a UITextField. I want to increase the size of this UITextField.
...
-1
votes
2
answers
558
views
UIStackView does not respect size of programmatically added buttons
I have a UIStackView that includes either three or four custom UIButtons. All buttons are completely rounded, the left and right buttons are slightly bigger than the center one/two. Somehow, I can't ...
1
vote
0
answers
394
views
Purpose of negative CGSize values
Been reading the docs and found out that CGSize can take in negative values since it's more of a "vector" representation.
What's the purpose of this? Not saying that vectors can't be ...
1
vote
2
answers
1k
views
Size UITextView to fit multiline NSAttributedString
I have a UITextView containing an NSAttributedString. I want to size the text view so that, given a fixed width, it shows the entire string without scrolling.
NSAttributedString has a method which ...
0
votes
1
answer
3k
views
How to get UIView height and width in Swift? (problem: returning zero)
Sorry in advance for the probably silly question - I'm a beginner
I'm generating a new UIView in viewDidLoad, providing some constraints to anchor it over the main view. When it comes to understand ...
0
votes
2
answers
173
views
Swift -meaning of viewportSize parameter of projectPoint(_:orientation:viewportSize:)
The Apple doc for
func projectPoint(_ point: simd_float3, orientation: UIInterfaceOrientation, viewportSize: CGSize) -> CGPoint
says:
viewportSize
The size, in points, of the view in which the ...
0
votes
2
answers
2k
views
How to convert pixel dimension to CG Size in Swift?
I have large images uploaded by users in Swift and I need to resize them all to 100x100px to create thumbnails to store in my server. So far I have found that this resizes an image given a CGSize:
...
0
votes
1
answer
929
views
Swift -Frame dimensions for portrait video
If I want to display a 16:9 horizontal video inside a cell I use the dimensions:
let videoHeight = self.frame.size.width * 9 / 16
contentView.addSubview(thumbnailImageView)
thumbnailImageView....
0
votes
1
answer
2k
views
Swift -how to make a smaller version of a 16:9 video thumbnail but keep the aspect ratio the same
The aspect ratio for a 1080p hd video is 16:9 and to set a frame for the video in a cell so that it would fill it up completely I would use view.frame.width * 9 / 16:
func collectionView(_ ...
0
votes
1
answer
91
views
space position objects by proportion
My swift code below is positioning objects. I want both objects to be to cover 10 percent of the x axis each. So the first object which is fight[0].image and the 2nd object is fight1.image. As you can ...
0
votes
0
answers
400
views
How to calculate the size of a non full screen page sheet view on iPad
Im trying to calculate the width of this view not the entire screen but i'm getting the whole screen width not the page sheet view on iPad.
On iPhone it is fine because the page sheet covers the ...
1
vote
2
answers
1k
views
CGSize is not accepting `.zero`. Ambiguous use of 'init(width:height:)'
In UICollectionViewDelegateFlowLayout when I am using:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: ...
2
votes
1
answer
729
views
Expand UITextView and then scroll after certain point
I have been struggling to set create this, I have read numerous posts on here, but do not understand what I am doing wrong.
I have a UITextView.
I would like it to expand in height, up to a number ...
-2
votes
2
answers
394
views
Is there no way to determine actual/correct NSString boundingRect height for any/random UIFont?
I have tried everything I found on StackOverflow but nothing worked really.
I need to calculate boundingRect's height for any/random UIFont available.
The code is simple (I modified some of the code ...
1
vote
0
answers
2k
views
CGSize to pixels / points confusion
I have got this code:
CGRect _frame = container.frame;
CGFloat height = _frame.size.height
This code gives me the height of the view but in what units? Is there a way to convert it to pixels or ...
0
votes
1
answer
233
views
How to fix 'Expression type 'CGSize' is ambiguous without more context' in swift?
This is my code :
@IBOutlet weak var imageScroll: UIScrollView!
...
imageScroll.contentSize = CGSize(width: imageScroll.visibleSize.width * 5, height: imageScroll.visibleSize.height)
It's OK.
If I ...
1
vote
1
answer
50
views
Dynamic sized collectionView cell causing visibility issue - iOS
I have a 3 columns and multiple rows Collection View. In my sizeForItemAtIndexPath, I return a dynamic CGSize like this :
return CGSizeMake(_sponsoredCollectionView.frame.size.width/3 - 7, (...
0
votes
1
answer
81
views
How is CALayer.shadowOffset set from CGSize?
If I do view.layer.shadowOffset = CGSize(width: -1, height: 1) what exactly does the numbers -1 for width, and 1 for height mean? How is the shadow determined from the CGSize passed? I found the ...
0
votes
1
answer
796
views
Multi-line UILabel causing extra padding
I have a collectionView cell that has a label and an imageView. The imageView is 8 points from the top of the cell, the top of the label is 8 points from the bottom of the imageView, and the bottom of ...
2
votes
1
answer
2k
views
Faster way to estimate cell height in a CollectionView
I have an infinite scroll in my UICollectionView and I've noticed that the way I estimate my cell height is the bottleneck of my collection view. It causes some long delays the more I scroll my ...
0
votes
1
answer
229
views
Xcode: Argument passed to call that takes no arguments
I'm currently working on an App where Meteors should spawn randomly as enemies. I have this code:
let randomXStart = random(min: CGSize, max: CGSize)
let randomXEnd = random(min: CGSize, max: CGSize)
...
-3
votes
1
answer
336
views
Aspect fit in cgsize programmatically in swift [closed]
Click here for image.
Need help fitting label so that the left and right side fills.
Code is at the bottom.
@IBOutlet weak var header: UILabel!
override func viewDidLoad() {
header....
0
votes
0
answers
180
views
Why Xcode detects my iPhone 7 plus device as iPhone 5 with wrong screen scale and size?
I run my app on my iPhone 7 + device and when I try to log the Scale and screen bound sizes, What I get is related to iPhone 5/5s/5c/SE, NOT to my iphone 7 plus specification.
This is what I get in ...
5
votes
4
answers
12k
views
How set UIButton size by it's title size?
I have UIButton, which title is dynamic changes. Button size should changes with title size and will be equal title size.
How to do this programmatically in Swift?
0
votes
0
answers
198
views
sizing with pixels swift spritekit
I have a total newbie question with swift. I am running into an obstacle when sizing my nodes. I would like to size my nodes like this...
player.size = CGSize(width: 60, height: 60)
This comes out ...
0
votes
3
answers
2k
views
How to get CGFloat/CGSize based on String length?
I have a UIView, which acts as a container and the width of this container needs to change dynamically based on the longest String. So I want to get CGFloat/CGSize based on String length, is it still ...
-3
votes
1
answer
1k
views
Specific issue for CGSizeMake with Swift 3 Xcode 8 [duplicate]
I'm having an issue with the youtube video by Jared Davidson. https://www.youtube.com/watch?v=1_daE3IL_1s At exactly 7 minutes, he writes the code line:
self.ScrollView1.contentSize = CGSizeMake(self....
6
votes
2
answers
2k
views
SpriteKit - get absolute size of SKNode
I'm programming a small game in Swift and SpriteKit, which is made of a boxes (4 * 8).
Scene (1024 * 768)
boxes (964 * 452)
row1 (932 * 25)
col1 (24 * 116)
col2 (...
1
vote
1
answer
3k
views
In Swift 3, How to change the resolution on the selected image in Pickerview Controller
The resolution of the original image selected in imagePickerControllerd is 2448x3264.
I want to keep the ratio and change the resolution.
I need help.
0
votes
2
answers
2k
views
How do I create constants of type CGSize in header file in iOS?
I want to create constants in header file of type CGSize so I can use this size anywhere in my app just using constantName.height and constantName.Width.
I would appreciate if you provide syntax for ...
0
votes
5
answers
1k
views
UILabel get Frame width or height
`lblAddress.frame.width`
`lblAddress.frame.size.width`
I have searched so many time but still i haven't point out...what is difference between lblAddress.frame.width AND lblAddress.frame.size.width. ...
0
votes
1
answer
395
views
Calculations of the 80% of screen and 20% in UICollectionView
I write function that return size of the cell for the UICollectionView.
fileprivate func getCellSize(with row: Int) -> CGSize {
let percentage: CGFloat = row == 0 ? 0.8 : 0.2
...
1
vote
1
answer
106
views
add uiColor for cgsize (swift3)
Right now newSize just creates a white box. I would like newSize to be a blue box. How do I add uiColor to newSize?
let newSize: CGSize = CGSize(width: 900, height: 900)
...
0
votes
1
answer
653
views
How to convert metric/Inch to CGSize - Swift
I need to render a PDF for a given metric size. I can render a PDF in iOS coordinates but how can I convert i.e. 1mm to points.
Thanks
18
votes
1
answer
43k
views
how to set scrollview content size in swift 3.0 [duplicate]
After updated Xcode8 not able to set contentSize for ScrollView. I can't able to use CGSizeMake.
Can anyone help me?
I have tried
scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 700)...
18
votes
2
answers
4k
views
Only First Track Playing of AVMutableComposition()
New Edit Below
I have already referenced
AVMutableComposition - Only Playing First Track (Swift)
but it is not providing the answer to what I am looking for.
I have a AVMutableComposition(). I ...
8
votes
1
answer
7k
views
func collectionViewContentSize in Swift3
I have update my Project to Swift3 in Xcode 8 and it comes this error but I have no idea what I can make there. I have already search in google but nothing founded.
Have anyone an Idea what I can make ...
0
votes
1
answer
219
views
IOS create textsize with CGSize depreciated method
Hi i am reacreating the textsize with these code
CGSize textSize = [self.text sizeWithFont:self.font
constrainedToSize:self.frame.size
...
1
vote
0
answers
133
views
Tableview inside a ViewController in container view changes layout on rotate
I kept a tableview inside a viewController.ViewController is inside a container view.
The problem is that the layout changes on rotation of the device.
This is not a constraint issue as it happens ...
0
votes
1
answer
99
views
bounds.size cannot get the correct real time size
I have a UIView object in a view controller and wanna add a CALayer object into the UIView object.
The auto layout configuration of the UIView object is shown as follows. (Sorry I cannot embed pix yet,...
5
votes
3
answers
4k
views
What's the difference between using CGSizeMake and CGSize? Is one better than the other?
CGSize(width: 360, height: 480) and CGSizeMake(360, 480) seem to have the same effect. Is one preferred to the other? What is the difference?
-3
votes
1
answer
2k
views
What does .f mean in CGSize in Objective-C? [duplicate]
This must be in documentation somewhere but I cannot find it. What does the .f mean when defining rectangles using CGSizeMake as in CGSizeMake(200.0f, 100.0f);?
2
votes
1
answer
713
views
Compare two CGSize's to best persentage
Need your help, I have input CGSize (for example): 200x300. And array with other CGSize's = [20x20, 100x100, 150x150, 200x100, 200x250, 300x300...].
Please help me to find best item in array that have ...
-4
votes
1
answer
185
views
need help about resize image swift 2
My app retrieves image from URL, but I need to change the image size before it appears on the user interface in my tableview.
this is my code in my tableViewController:
import UIKit
import Firebase
...
6
votes
2
answers
2k
views
Resize MoPub iOS banner ad?
I need to have my banner ads stratched/filled all across the width of the screen at the bottom.
My code is working for the devices with the width equal to either MOPUB_BANNER_SIZE.width or ...
6
votes
4
answers
2k
views
Adjust cell width based on text - UICollectionView - iOS
I have an iOS app with a UICollectionView which presents cells horizontally. In each of the cells, I have added one simple label (for now). These labels are showing names, sometimes the names are ...
1
vote
2
answers
105
views
Image getting bigger after saving it
I would be grateful if anyone could help me to solve an issue with image saving.
I've got an app which contains recipes with corresponding images. I need to resize them in order to preserve memory and ...
0
votes
2
answers
966
views
Resizing UIImageView without scaling UIImage
I have a UIImageView that display a UIImage with the content mode set with UIContentModeScaleAspectFit. The imageview is as width as the screen. I want to resize the imageview without changing image ...
1
vote
2
answers
923
views
Swift ScrollView - contentSize can't take a variable Int
Trying to set a scrollView's contentSize and I've run across this issue (Xcode 6.4)...
Both of these work perfectly:
scrollView.contentSize = CGSize(width:self.view.frame.width, height:1000)
...