The title says it all.
Is there a way to render a SwiftUI View to a moviefile in background?
An ideal solution would be, that the View being captured is not even displayed on screen.
I read about some answers on how to capture a MTKView and thought about accessing the underlaying view of drawingGroup(). Despite a lot of research I couldn't find any way to access it.
On the other hand, there is the inelegant way to render and capture the view as an UIView.
Thanks in advance!
Related
I know there are many questions and answers about how to make a ViewController full screen. My problem is little odd. I am not using Navigation Bar and when I try to set my modalPresentationStyle to fullScreen my View is showing and than hiding.
This is probably due to code you have not shown us, such as a bad viewWillDisappear in the previous (select place to ride) view controller.
You didn't experience the issue before because a presented view controller that isn't full screen doesn't cause the previous view controller to disappear.
I got a problem with Cocoa and its View redraw hierarchy.
I'm currently testing displaying (audio) levels in a meter style control and I'm using the MeteringView class from MatrixMixerTest example project from apple. This class is drawing the meter and only drawing the difference what got changed which looks like a very efficient class.
My project is splitted into 2 splitviews, in some are NSCollectionViews (Scrollview, Clipview) and in others are only static views. If I add the meter to those "static" views they work fine when these views call setNeedsDisplay:YES. If a meter is added to the view of a CollectionView Item it gets rendered, but loosing its drawn "old level" parts and its corners/background. I think this happens because the CollectionView item gets also called to be redrawn (which has a background image) and everything is gone. It is drawing some parts whats currently changing (the drawing works).
Is there a way to prevent the Item itself to be redrawn? Or, I dont know why it is not happening in those static views, because those views also have background images but do not draw over the meter.
Are there some tricks or whats different in a CollectionView than in a "normal" view?
EDIT: After reading about isOpaque (MeteringView isOpaque = YES) means it should not call the parent views drawRect if set to yes. Well that works for the static views, those MeteringViews do not call parents drawRect, but those in a CollectionView do however. I dont know why.
EDIT 2: I gave this topic another title, because isOpaque=YES in MeteringView is not stopping calling the parents drawRect in a CollectionView, in a normal view it is working. Are there some things to know about? I have to stop redrawing the CollectionView Item because thats the problem.
Thanks in advance guys
Benjamin
isOpaque is just hint to the system. It does not prevent other views from drawing their contents, it only means that it can sometimes skip making other views update their contents.
If your view is opaque, it should draw itself as opaque and completely fill its bounds.
Id like to add an overlay to an NSTableView when it is loading some data. I found this post which mentions using CALayer with a CIGaussianBlur but I cannot get anything to work. Does anyone know of any good tutorials for displaying an overlay on an NSTableView? (Or even just an NSView).
I've always found it easiest to do this by not futzing with the table view at all. Embed the table as a subview of another view (a container view, if you will). Add another subview to the container view that will be your overlay, just make sure it's in front of your table. Then you hide the overlay view when you don't need it, show it when you do.
I have been trying to create a simple swipe transition. However buttons seem immune to any CAAnimation that crops.
I am trying to get it so that a bar moves across the screen and as it goes over the button it removes the part it has just gone over.
I have tried bounds.width, size.x and many other key-value paths to achieve the affect but I haven't got what I wanted. It just relocates the text which always remains entirely visible
I have also tried changing the UIButton to a UIImage but the text does not seem to print on a UIImage.
I tried using masks too but I have heard they should be used as infrequently as possible as they consume the phones resources. I didn't really get very far with this either anyway as I hadn't used them much before.
I also tried placing it in a container view and then change the dimensions of that but again all of the text remained entirely visible.
I know I could have a view hide the button but I am trying to reveal the view behind as the bar swipes.
Does anyone have any suggestions of how to achieve a swipe transition on a UIButton?
Help would be much appreciated.
Thanks
I think what you're looking for really is a mask. See the tutorial here:
http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
What I'd do in your situation is create a custom UIButton class, and add a mask as in the tutorial, then animate the position of the mask. Slide the mask of, nothing shows. Slide it on, part shows until the whole thing is visible.
Edit: I haven't really heard anything about hogging resources, especially since it appears to be simple core graphics.
I am trying to implement a print view for use with an NSPrintOperation which uses many WebViews for rendering content. Think of keynote-like slides, where each slide is a WebView.
To do this efficiently, I am trying to just add the WebViews that are needed for the current page.
I have tried adding the WebViews directly as subviews of the main print view, but the WebView does not layout properly, even if I delay returning from the printing method to give it a chance to finish.
I then tried using cacheDisplayInRect:toBitmapImageRep: on the WebViews, and using the result in an NSImageView instead of adding the WebViews directly to the print view. This works, but the print quality of a bitmap is not as good as I would like.
Lastly, I thought I could instead generate a PDF, and use that. But the dataWithPDFInsideRect: method suffers from the original problem, where the layout is messed up.
How could I get the WebViews to layout properly when subviews of the printing view, or generate a PDF along the lines of cacheDisplayInRect:toBitmapImageRep: which could be used with NSImageView?
Seems I found a solution to this myself. If I use the method displayRectIgnoringOpacity:inContext: to draw each WebView, rather than adding them as a subview to the printing view, the layout is fine. Doing this is probably what cacheDisplayInRect:... is doing behind the scenes.