uiview

How to get Height of Safe Area Programmatically Prior to IOS 11?

断了今生、忘了曾经 提交于 2021-02-19 05:19:08
问题 Without using safeAreaLayoutGuide (I am targeting IOS 9+), is there any way to programmatically get the height of the "safe area" in IOS without having to create a new view (constrained to the safe area) solely for this purpose? I can't set an outlet to the safe area because it's not a UIView... or even a class of any sort. And if I simply use self.view.height in the ViewController, it's going to be too high (wrong). Is there some other way to do it? 回答1: In a UIViewController you can use the

How to get Height of Safe Area Programmatically Prior to IOS 11?

谁说胖子不能爱 提交于 2021-02-19 05:19:07
问题 Without using safeAreaLayoutGuide (I am targeting IOS 9+), is there any way to programmatically get the height of the "safe area" in IOS without having to create a new view (constrained to the safe area) solely for this purpose? I can't set an outlet to the safe area because it's not a UIView... or even a class of any sort. And if I simply use self.view.height in the ViewController, it's going to be too high (wrong). Is there some other way to do it? 回答1: In a UIViewController you can use the

Resume CABasicAnimation using negative speed?

邮差的信 提交于 2021-02-19 02:55:20
问题 I resume my CABasicAnimation with the following code: CFTimeInterval pausedtime = layer.timeOffset; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = [layer convertTime:CACurrentMediaTime() toLayer:nil] - pausedTime; which is pretty straightforward. At the very end of this article the author states that with negative speed value animation reverses. I can't understand what timeOffset and beginTime should look like in this case? P.S. I am aware that I can reverse animation by

Drawing a grid on a UIView in Swift

荒凉一梦 提交于 2021-02-19 00:51:24
问题 I am very new to Swift. Am trying to draw a grid (like a graph page) on a UIView in Swift. The code is running but I don't see any lines. I don't see what I did wrong. In the Storyboard I added a View onto the ViewController. In code I created a GridView.swift and added it to the View above. Here is the code for GridView class. The function draw is being called and the code running without any errors. Its just doing what I thought it would do. Its not even drawing one line (I remove the for

Drawing a grid on a UIView in Swift

谁说胖子不能爱 提交于 2021-02-19 00:51:22
问题 I am very new to Swift. Am trying to draw a grid (like a graph page) on a UIView in Swift. The code is running but I don't see any lines. I don't see what I did wrong. In the Storyboard I added a View onto the ViewController. In code I created a GridView.swift and added it to the View above. Here is the code for GridView class. The function draw is being called and the code running without any errors. Its just doing what I thought it would do. Its not even drawing one line (I remove the for

Drawing a grid on a UIView in Swift

两盒软妹~` 提交于 2021-02-19 00:51:15
问题 I am very new to Swift. Am trying to draw a grid (like a graph page) on a UIView in Swift. The code is running but I don't see any lines. I don't see what I did wrong. In the Storyboard I added a View onto the ViewController. In code I created a GridView.swift and added it to the View above. Here is the code for GridView class. The function draw is being called and the code running without any errors. Its just doing what I thought it would do. Its not even drawing one line (I remove the for

Drawing a grid on a UIView in Swift

微笑、不失礼 提交于 2021-02-19 00:51:13
问题 I am very new to Swift. Am trying to draw a grid (like a graph page) on a UIView in Swift. The code is running but I don't see any lines. I don't see what I did wrong. In the Storyboard I added a View onto the ViewController. In code I created a GridView.swift and added it to the View above. Here is the code for GridView class. The function draw is being called and the code running without any errors. Its just doing what I thought it would do. Its not even drawing one line (I remove the for

Drawing a grid on a UIView in Swift

徘徊边缘 提交于 2021-02-19 00:50:32
问题 I am very new to Swift. Am trying to draw a grid (like a graph page) on a UIView in Swift. The code is running but I don't see any lines. I don't see what I did wrong. In the Storyboard I added a View onto the ViewController. In code I created a GridView.swift and added it to the View above. Here is the code for GridView class. The function draw is being called and the code running without any errors. Its just doing what I thought it would do. Its not even drawing one line (I remove the for

Swift UIView draw diagonal one side and round corner

只谈情不闲聊 提交于 2021-02-11 12:22:40
问题 I am drawing some view with diagonal side like this: code: let layerWidth = layer.frame.width let bezierPath = UIBezierPath() let pointA = CGPoint(x: 0, y: 44) let pointB = CGPoint(x: 150, y: 0) let pointC = CGPoint(x: layerWidth, y: 0) let pointD = CGPoint(x: layerWidth, y:44) bezierPath.move(to: CGPoint(x: pointA.x, y: pointA.y) ) bezierPath.addLine(to: CGPoint(x: pointB.x, y: pointB.y)) bezierPath.addLine(to: pointC) bezierPath.addLine(to: pointD) bezierPath.close() let shapeLayer =

UITableViewCell gets reused and shows wrong drawing in UIView

人走茶凉 提交于 2021-02-11 12:14:30
问题 I've been having this problem for weeks and I think I am not able to solve it. I have a tableView which has custom tableViewCell s and they are filled with data. The tableViewCell has two UILabel s and one UIView . The problem appears when I scroll several times the drawings on the UIView s are overlapped one with another, I think they are redrawn. I know that this behavior is because of the reuse of the cells but I can't even locate the origin of the problem. UIViews show perfectly when