Translate camera's button text ("Cancel", "Retake" and "Use photo") in SwiftUI - camera

Once I've implemented camera functionality with this great tutorial ( https://www.hackingwithswift.com/books/ios-swiftui/importing-an-image-into-swiftui-using-uiimagepickercontroller ), I wonder if there'd be a way for translating the text of the camera buttons for something other than "Cancel", "Retake" and "Use photo". My goal is translating those texts to portuguese, but I just can't figure out how to do that on SwiftUI.

Related

Custom Titlebar in a Cocoa Application

I need to create a (very) custom titlebar in a cocoa app. I read about the INAppStoreWindow library, but it seems it doesn't have the feature that I need. So here's what I have need to do (see image for clarification):
My titlebar is the thing between the green and red circle
The text (Text1 - Text3) are all images
The black circle with the exclamation mark is also an image
The grey area below the title bar is a webview. It expands from the left border all the way to the right edge of the reddish sidebar. (This is actually where why I think that the INAppStoreWindow won't work, as I cannot specify a width for the title bar)
The images should have an Action
Text1 through Text3 as well as the black circle load some URL into the webview
Red circle closes the app
My app has no borders and no shadows. Right know in order to be able to move the app I drew a Box element at the top where the title bar should be. I think I can draw something in it as well, but as I'm very knew to cocoa development here are my questions:
How can I draw some images in the Box element?
Is there a better element to draw the titlebar in?
I know that are two questions, but they are closely relatated. It's generally: How to draw a simple titlebar like this?
As the problem inside the titlebar is the same for every item I need to draw (they are all images) I belive there is a quite simple solution for that, but because I lack the experience of how to solve this I'd need your help. You can also point me the the right direction in the comments and I'll answer this question myself after I've got it right.

How to use the default color picker in NSToolbar?

I'm learning Cocoa. And this is my simple OS X app:
It contains a custom view, where the white rect is drown, a toolbar, and a slider. I want to change the rect's fill color by clicking on the 'Colors' item in the toolbar and choosing new color in the color palette.
How can I get the new color from the palette? I know it has the "NSToolbarShowColorsItem" identifier, but don't know how to use it.
Can you please help me? Thanks.
You should probably consider walking through a couple of basic Cocoa tutorials to learn about fundamental Cocoa concepts.
A number of resources to check out:
CocoaDevCentral
Cocoa Fundamentals Guide
Tutorials on CocoaDev

iOS Text Wrapping

In the app I am currently developing, I have to implement a screen which allows the user to ask a question. This screen contains a UIImageView next to the UITextView, taking up a portion of the space. It looks like the below image.
My question is, how can I wrap the UITextView text around the UIImageView, so that the text won't be in a block, but flowing around the UIImageView?
Thanks in advanced.
I don't think you can do this, unless your UITextView was a rich text or HTML editor, with the image embedded inside it. Basically what you're asking for is a non-rectangular UITextView. To the best of my knowledge, that is impossible in iOS, unless you were to create something brand new from scratch, which would be extremely complex. I have seen plenty of UILabel-style controls that can display HTML-like text, but not edit it.
EDIT: this might help: http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
Unfortunately that's not a trivial issue as the UITextField does not provide any functionality that would be useful here.
However what you could do is to implement your own text view using UITextInput (for text input) and Core Text (for text display) and then define the drawing rectangle for Core Text (you can read more on Core Text here) from a custom CGPath that would exclude the images frame.
It does sound a bit complex (insane, perhaps), however as (nearly always) there are open source solutions that already found a solution. The OmniGroup framework contains custom text input controls based on Core Text and UITextInput. They're licensed under MIT License (well, moreless) so you should be just fine.

Zoom in and Out through a NSView or Magnify

I am hoping to be able to make something similar to the universal access zoom window shown below. I have already created an NSView and using a fill operation I made a rect with a clear "see through" composite to see through my window and show the desktop. Now I am wondering if it is possible to zoom in and out inside my view just like the picture below. I was thinking this might be an IkImageView or something I could apply but i wasent sure how it was done. Does anyone know how to do this or show me where I could find this in the docs? Some code would be great. Thanks!
Take a look at Apple's example CIAnnotation. In this example is magnifying image but I think You can achieve what You want. You can download sample code from here.
CIAnnotation app example:
References and guides which can help You with this:
Core Image Programming guide
Quartz 2D Programming Guide
NSGraphicsContext Class Reference
NSView supports zoom through - (void)scaleUnitSquareToSize:(NSSize)newUnitSize
This zooms the content of the view, so to use this you would have to set the Desktop behind the mouse as view content (NSImage maybe?) and then zoom the view. It will have to update when the mouse is dragged.
Check the ImageKit part of Quartz, in particular the class IKImageView. It has zoom features, but I have not worked with it myself yet.

Tips on implementing a custom UITextView interface on the iPhone?

I am trying to implement a control to edit text that will display the text in multiple colors. None of the solutions I have attempted yet have been good enough.
UITextView cannot accomplish this. All of the text must be the same color.
Using CoreGraphics to draw the text does not allow the text to be selected.
Using a UIWebView, DIV and PRE tags cannot be set to contentEditable on Mobile Safari.
Currently playing with using an off-screen TEXTAREA and an on-screen DIV to show the rendered text. This works pretty well, except supporting all of these at the same time seems impossible: click-to-type, click-to-move-cursor, click-and-hold-select/copy/paste.
Anyone have any tips on this predicament?
I've been trying to find any preexisting library out there that will accomplish this in a good way, to no luck. I'm open to any ideas!
Well, just pulling an idea out of my... let's say hat.
Could you put a transparent UITextfield over a view that draws the text? If the background was clear and the text color was clear the user could not perceive it but it should still respond to all commands. As the user enters and edits text you could draw the results on the view underneath.
I think the selection would work without any modification at all. When the user selected the clear text, it should create the illusion of selecting the drawn text automatically.
Like this one? StyledText http://three20.info/gfx/overview/styledtext.png It's in Three20 .
Here is an idea. I have no idea if it would work.
If you are only using colors, and not styles, the a UIWebView with colored text might layout text in exactly the same way as a UITextView. You could put a UITextView with invisible ink (text and background fully transparent) over a UIWebView and mirror the contents with colors in the html. I assume you can do scrolling with javascript along with the colored layout.