uikit

Difference between CurrentValueSubject and @Published

旧城冷巷雨未停 提交于 2021-02-18 22:10:53
问题 So I'm digging into combine and this question came up. Is there any real difference between using CurrentValueSubject (and setting its value using currentValueSubject.value ) or using a @Published var and accessing its publisher with a $ ? I mean I know one returns a Subject instead of a Publisher , but the only real difference I could find is that CurrentValueSubject is way more useful because you can declare it on a protocol. I really don't understand how @Published can be useful if we can

How to add placeholder text to TextEditor in SwiftUI?

半世苍凉 提交于 2021-02-18 05:07:09
问题 When using SwiftUI's new TextEditor, you can modify its content directly using a @State. However, I haven't see a way to add a placeholder text to it. Is it doable right now? I added an example that Apple used in their own translator app. Which appears to be a multiple lines text editor view that supports a placeholder text. 回答1: It is not possible out of the box but you can achieve this effect with ZStack or the .overla y property. What you should do is check the property holding your state.

Throwing paper/ball effect animation in Swift UIKit

喜欢而已 提交于 2021-02-11 12:28:48
问题 What would be the best way to create a throwing paper/ball effect animation in UIKit? What I need is basically a throwing effect starting from point A and ending at Point B . I don't need any bouncing effects, this is more of an effect to let the user know that something was added from point A to Point B ; similar to the effect we get when we add a photo to an album in Photos. I have been playing around with animateKeyframes but I cannot quite get the effect I want, I'm not getting the curve

SwiftUI: How to connect currentPage of PageView with firing view's passing index

邮差的信 提交于 2021-02-11 12:11:16
问题 I follow Apple's example interfacing-with-uikit to use PageView in SwiftUI. And I want to implement it in my app. The scenario is that in MovieView , when the user taps an image of image list then it triggers call to PageView with views and selected index as parameters. But when I click on any item of image list, it always show the page view with the 1st element. I try to change it in init() of PageView , however it is not working. In console, I try to print something, and I see the

SwiftUI - Determining Current Device and Orientation

感情迁移 提交于 2021-02-11 04:31:16
问题 I am trying to detect when the device is on iPad and in Portrait. Currently I use the UIDevice API in UIKit and use an environment object to watch changes. I use the solution found here - Determining Current Device and Orientation. However the orientationInfo.orientation is initially always equal to .portrait until rotated into portrait and then back to landscape. So when doing the following to display the FABView struct HomeView: View { @EnvironmentObject var orientationInfo: OrientationInfo

iOS 14下面图片无法加载,包括weex、YYAnimateView、SDAnimatedImageView

≡放荡痞女 提交于 2021-02-10 17:53:57
升级xcode12后,编译运行App发现大片大片的图片加载不出来,包括weex的图片和YYAnimateView的图片都有问题。 经过一番研究之后,发现是iOS 14下UIKit对 `displayLayer:`的处理机制有所变化。 `displayLayer:`是`CALayerDelegate`的代理方法。在iOS 14之前,UIKit在调用这个方法之前就会去渲染`UIImageView.image`。 而在iOS 14,UIKit则是先去调用代理方法,如果你实现了`displayLayer:`这个方法,那么UIKit就不会再去渲染了。 如果改成下面这样就可以正常加载了: ``` - (void)displayLayer:(CALayer *)layer { UIImage *currentFrame = _curFrame; if (currentFrame) { layer.contentsScale = currentFrame.scale; layer.contents = (__bridge id)currentFrame.CGImage; } else { // If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method

UIPageViewController stops working after 1 swipe in SwiftUI

≡放荡痞女 提交于 2021-02-10 15:16:13
问题 I was following the Apple tutorial for SwiftUI and under 'Interfacing with UIKit' (https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit) we were made to make a UIPageController. In the tutorial, they used a State property to update the currentPage variable in PageView . I wanted to experiment a little bit and decided that I want to embed the PageView in a different view and have a currentPage property update in that parent view instead. So, naturally, I changed the @State

UIPageViewController stops working after 1 swipe in SwiftUI

时间秒杀一切 提交于 2021-02-10 15:15:25
问题 I was following the Apple tutorial for SwiftUI and under 'Interfacing with UIKit' (https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit) we were made to make a UIPageController. In the tutorial, they used a State property to update the currentPage variable in PageView . I wanted to experiment a little bit and decided that I want to embed the PageView in a different view and have a currentPage property update in that parent view instead. So, naturally, I changed the @State

ios

人走茶凉 提交于 2021-02-10 06:23:28
#import <UIKit/UIKit.h> @interface ScrollUpDownView : UIView // 设置 要现实的文字 @property(nonatomic, strong)NSArray * array; // 开启定时器 - ( void )onOpenTimer; // 关闭定时器 - ( void )onOffTimer; @end #import " ScrollUpDownView.h " @interface ScrollUpDownView () @property(nonatomic, weak)UILabel * label1; @property(nonatomic, weak)UILabel * label2; @property(nonatomic, assign)NSInteger count; @property(nonatomic, strong)NSTimer * timer; @property(nonatomic, assign) CGFloat mainH; @property(nonatomic, assign) CGFloat mainW; @property(nonatomic, assign) CGFloat mainX; @property(nonatomic, assign) CGFloat