cgsize

how to set scrollview content size in swift 3.0 [duplicate]

风格不统一 提交于 2019-12-01 14:38:21
问题 This question already has answers here : CGRectMake, CGPointMake, CGSizeMake, CGRectZero, CGPointZero is unavailable in Swift (10 answers) Closed 3 years ago . 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) 回答1: From Swift 3 CGSizeMake is not available use CGSize init instead. scrollView.contentSize = CGSize(width: self.view.frame.size.width

What's the difference between using CGSizeMake and CGSize? Is one better than the other?

血红的双手。 提交于 2019-11-30 15:27:48
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? The CGSize constructor is a Swift extension on CGSize : extension CGSize { public static var zero: CGSize { get } public init(width: Int, height: Int) public init(width: Double, height: Double) } CGSizeMake is a leftover inline function bridged from Objective-C: /*** Definitions of inline functions. ***/ // ... public func CGSizeMake(width: CGFloat, _ height: CGFloat) -> CGSize Both have the same functionality in Swift, the CGSize constructor is just

What's the difference between using CGSizeMake and CGSize? Is one better than the other?

孤者浪人 提交于 2019-11-29 21:27:22
问题 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? 回答1: The CGSize constructor is a Swift extension on CGSize : extension CGSize { public static var zero: CGSize { get } public init(width: Int, height: Int) public init(width: Double, height: Double) } CGSizeMake is a leftover inline function bridged from Objective-C: /*** Definitions of inline functions. ***/ // ... public func CGSizeMake(width: CGFloat

How to get device width and height?

断了今生、忘了曾经 提交于 2019-11-29 20:50:17
In Objective-C we can get device width and height by using following code : CGRect sizeRect = [UIScreen mainScreen].applicationFrame float width = sizeRect.size.width float height = sizeRect.size.height How can do this in with Swift ? iPatel I haven't tried but it should be.. var bounds = UIScreen.main.bounds var width = bounds.size.width var height = bounds.size.height @Houssni 's answer is correct, but since we're talking Swift and this use case will come up often, one could consider extending CGRect similar to this: extension CGRect { var wh: (w: CGFloat, h: CGFloat) { return (size.width,

Difference between frame.size.width and frame.width

浪子不回头ぞ 提交于 2019-11-29 09:31:53
I was writing a program in swift and just now I noticed that I can directly access a CGRect frame's width and height properties directly without using the CGSize width and height. That is I am now able to write a code like this. @IBOutlet var myView: UIView! override func viewDidLoad() { super.viewDidLoad() var height = myView.frame.height var height1 = myView.frame.size.height } In Objective C, when I tried to write the same code, the line height = view.frame.height is throwing an error. Can anyone please tell me the difference(if any) in these two lines of code. I just looked into the CGRect

CGSize sizeWithAttributes in Swift

我与影子孤独终老i 提交于 2019-11-28 20:47:53
问题 In objective-C I was able to use: CGSize stringsize = [strLocalTelefone sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}]; But in Swift Language I didn't found any solution for this situation. Any Help? 回答1: Just one line solution: yourLabel.intrinsicContentSize.width for Objective-C / Swift This will work even your label text have custom text spacing. 回答2: what I did is something like this: swift 5.x let myString = "Some text is just here..." let size: CGSize =

How to get device width and height?

北战南征 提交于 2019-11-28 16:57:03
问题 In Objective-C we can get device width and height by using following code : CGRect sizeRect = [UIScreen mainScreen].applicationFrame float width = sizeRect.size.width float height = sizeRect.size.height How can do this in with Swift ? 回答1: I haven't tried but it should be.. var bounds = UIScreen.main.bounds var width = bounds.size.width var height = bounds.size.height 回答2: @Houssni 's answer is correct, but since we're talking Swift and this use case will come up often, one could consider

Proper usage of intrinsicContentSize and sizeThatFits: on UIView Subclass with autolayout

家住魔仙堡 提交于 2019-11-27 17:06:22
I'm asking this (somehow) simple question just to be finicky, because sometimes I'm worried about a misuse I might be doing of many UIView's APIs, especially when it comes to autolayout. To make it super simple I'll go with an example, let's assume I need an UIView subclass that has an image icon and a multiline label; the behaviour I want is that the height of my view changes with the height of the label (to fit the text inside), also, I'm laying it out with Interface builder, so I have something like this: with some constraints that give fixed width and height to the image view, and fixed

iphone - how can i get the height and width of uiimage

廉价感情. 提交于 2019-11-27 10:18:12
From the URL Image in Mail I'm adding image to mail view. It will show full image. But I want to calculate, proportionally change the height and width of the image. How can I get the height and width of UIImage ? Jgubman let heightInPoints = image.size.height let heightInPixels = heightInPoints * image.scale let widthInPoints = image.size.width let widthInPixels = widthInPoints * image.scale Use the size property on the UIImage instance. See the documentation for more details. Salim UIImage *img = [UIImage imageNamed:@"logo.png"]; CGFloat width = img.size.width; CGFloat height = img.size

Only First Track Playing of AVMutableComposition()

不羁岁月 提交于 2019-11-27 06:38:34
问题 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 am trying to apply MULTIPLE AVCompositionTrack , of a single type AVMediaTypeVideo in this single composition. This is because I am using 2 different AVMediaTypeVideo sources with different CGSize 's and preferredTransforms of the AVAsset 's they come from. So, the only way to apply their specified