uikit

UIScrollView draw ruler using drawRect

狂风中的少年 提交于 2021-01-29 10:48:49
问题 I am trying to draw a ruler on top of UIScrollView. The way I do it is by adding a custom view called RulerView. I add this rulerView to superview of scrollView setting its frame to be same as frame of scrollView. I then do custom drawing to draw lines as scrollView scrolls. But the drawing is not smooth, it stutters as I scroll and the end or begin line suddenly appears/disappears. What's wrong in my drawRect? class RulerView: UIView { public var contentOffset = CGFloat(0) { didSet { self

Having textfield background transparent, but placeholder text opaque

折月煮酒 提交于 2021-01-28 13:50:40
问题 Is it possible to have a textfield's placeholder text opaque while its background is set to be transparent, eg. if I choose some background color, and set alpha to some value, like this: the placeholder text becomes transparent as well. But I want it opaque. So, is this achievable, preferably using storyboard ? Or at least through the code. If it is unclear what I am trying to achieve, just let me know , and I'll post an image with an example. 回答1: You can set the color's transparency instead

Custom UIWindow not showing

核能气质少年 提交于 2021-01-28 02:51:11
问题 I create a custom window let alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds) let background = UIToolbar(frame: alertWindow.frame) background.barStyle = .Black background.translucent = true alertWindow.addSubview(background) alertWindow.makeKeyAndVisible() It only appears if I put the UIWindow variable as the global variable inside the AppDelegate. I see many Pods out there that using custom UIWindow for notification banner or custom AlertView. But they didn't put their custom

Custom UIWindow not showing

孤者浪人 提交于 2021-01-27 23:41:05
问题 I create a custom window let alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds) let background = UIToolbar(frame: alertWindow.frame) background.barStyle = .Black background.translucent = true alertWindow.addSubview(background) alertWindow.makeKeyAndVisible() It only appears if I put the UIWindow variable as the global variable inside the AppDelegate. I see many Pods out there that using custom UIWindow for notification banner or custom AlertView. But they didn't put their custom

willMoveToWindow is called twice

柔情痞子 提交于 2021-01-27 06:28:27
问题 I'm swizzling willMoveToWindow: and I came across an issue where it was being called twice on views. When a new view controller is pushed onto a UINavigationController , willMoveToWindow: is called on the existing view with nil value (Makes sense since the view is moving offscreen) After that time, the method willMoveToWindow: is called again , but now with with the original window. My initial thought is that swizzling and calling the window property before the original method has kicked in.

willMoveToWindow is called twice

怎甘沉沦 提交于 2021-01-27 06:27:10
问题 I'm swizzling willMoveToWindow: and I came across an issue where it was being called twice on views. When a new view controller is pushed onto a UINavigationController , willMoveToWindow: is called on the existing view with nil value (Makes sense since the view is moving offscreen) After that time, the method willMoveToWindow: is called again , but now with with the original window. My initial thought is that swizzling and calling the window property before the original method has kicked in.

Xcode - Debug View Hierarchy

走远了吗. 提交于 2021-01-27 03:53:15
问题 I'm trying to debug my app's view hierarchy and a little purple square appeared on the left pane of Xcode's window (see screenshot). Any idea what that issue could be? 回答1: Alright! I found where this issue comes from… It's a constraint issue!!! 来源: https://stackoverflow.com/questions/49664266/xcode-debug-view-hierarchy

Xcode - Debug View Hierarchy

僤鯓⒐⒋嵵緔 提交于 2021-01-27 03:50:19
问题 I'm trying to debug my app's view hierarchy and a little purple square appeared on the left pane of Xcode's window (see screenshot). Any idea what that issue could be? 回答1: Alright! I found where this issue comes from… It's a constraint issue!!! 来源: https://stackoverflow.com/questions/49664266/xcode-debug-view-hierarchy

How do I use the Google Mobile Ads SDK in SwiftUI, or use the UIKit UIViewController within a SwiftUI view?

十年热恋 提交于 2021-01-20 22:01:40
问题 I have a SwiftUI view that I want to open a rewarded ad from the Google Mobile Ads SDK when I press a button. The instructions for loading the ads (https://developers.google.com/admob/ios/rewarded-ads#create_rewarded_ad) are in UIKit, and I'm struggling to use them in my SwiftUI app. Is there a way to load the ads using SwiftUI, or if I use UIKit, how do I integrate it into SwiftUI? This is the SwiftUI parent view: struct AdMenu: View { var body: some View { NavigationView { NavigationLink

How do I use the Google Mobile Ads SDK in SwiftUI, or use the UIKit UIViewController within a SwiftUI view?

冷暖自知 提交于 2021-01-20 21:58:59
问题 I have a SwiftUI view that I want to open a rewarded ad from the Google Mobile Ads SDK when I press a button. The instructions for loading the ads (https://developers.google.com/admob/ios/rewarded-ads#create_rewarded_ad) are in UIKit, and I'm struggling to use them in my SwiftUI app. Is there a way to load the ads using SwiftUI, or if I use UIKit, how do I integrate it into SwiftUI? This is the SwiftUI parent view: struct AdMenu: View { var body: some View { NavigationView { NavigationLink