watchOS 7: How to render an inset grouped list as in the watchOS 7 Camera app? - watchos

(Cross post: https://developer.apple.com/forums/thread/657933)
At around 8:47 in the WWDC 2020 video "What's New in watchOS Design", in the example of a More button for the watch Camera app, a sheet is presented with a "robust set of options" which are rendered in a style somewhat similar to the iOS UITableViewStyle.insetGrouped / InsetGroupedListStyle. However, InsetGroupedListStyle isn't exposed on watchOS 7.
The closest analog I could see was when you embed a Picker into a List, the picker is rendered as a title/subtitle cell, and tapping on that cell presents a modal sheet with that one Picker's list of options in the same inset grouped style. However, this isn't an exact match - this picker has to be in a list, rather than a More button, and the picker only selects from one set of options, as opposed to multiple heterogeneous groups of options.
Can anyone provide guidance on how to render a sheet with multiple, heterogeneous groups of options, like the Camera app's More sheet, in this video?

Related

Add Stickers in Custom KeyBoard Extension

I am looking to create a Custom Keyboard for iPhone,iPad. I have successfully integrated Phrases and Emoticons into the Keyboard, But couldn't get any idea how to add stickers in the keyboard.
Anyone knows how to add ?
Thanks.
I recently created a custom keyboard for sending stickers on iPhone. I noticed this question is tagged as Objective-C but I will be responding in Swift since that’s how I did it.
If I am understanding your question correctly, “add stickers in the keyboard” may refer to stickers similar to those on Facebook Messenger or Peach. My personal inspiration came from wanting to create something similar to Kim Kardashian’s KIMOJI app. This custom keyboard extension works by allowing the user to tap on a sticker, copy it, and then paste it into an input field to send.
To begin with, I found this great custom keyboard tutorial on AppCoda: Creating a Custom Keyboard Using iOS 8 App Extension (written in Swift). The tutorial walks you through how to create a new keyboard extension within an app, add a view which holds buttons (or keys), and apply appropriate constraints. However, I found all the details of creating keys less necessary for a sticker keyboard.
Following the tutorial, once you create a basic keyboard with a KeyboardViewController and KeyboardView xib, I added UIButtons. In my case, I added six buttons to correspond to six stickers. The first UIView row and second UIView row both held three buttons each. I applied constraints so that each button was equal height and width (approximately 100 x 100). In Storyboard, I clicked on each button and in the attributes inspector I set the button “image” property to the corresponding sticker image I had in my assets. Also, to determine an appropriate height for my keyboard, I found this helpful resource: iPhone Development 101 - iPhone & iPad Keyboard Sizes.
Note: In order to create stickers you need images of some sort. I drew / designed my own. You could also design them using Adobe Illustrator or an equivalent program.
Once you set the images for each button and run the app, the images may not appear. To fix this, I had to visit my sticker keyboard Target > Build Phases > Copy Bundle Resources to ensure Assets.xcassets was included. Running the app again, the images appeared.
Next, assuming you have created a KeyboardViewController that corresponds to your KeyboardView.xib, you can create a corresponding #IBAction for each button/sticker in the view controller. We want the user to copy the sticker selected to Pasteboard so they can send the stickers. To enable your custom keyboard to access Pasteboard, go into the keyboard extension’s Info.plist file. Under Information Property List > NSExtension > NSExtensionAttributes, change the RequestsOpenAccess property to YES.
Now, the IBAction method you created can assign the appropriate sticker image path to the Pasteboard! This is very generally how my code looked:
#IBAction func stickerPressed(sender: UIButton) {
let image = UIImage(named: "sticker")
UIPasteboard.generalPasteboard().image = image
}
When you run and test your app on a device and install it, click the globe icon on the keyboard to switch to your custom keyboard. Tap on a button/sticker, then tap in an input field to paste. In Facebook Messenger, options may appear to “Send Photo” “Edit” or “Cancel.” In Peach or Messages, it will send inline. It just depends on the app.
This process worked for me and I hope it can help someone else out there!
You can create UIImageView inside UICollectionView or UITableView, and show sticker images inside these UIImageViews. And when user taps on them, just get the UIImage present in that view.

Yosemite Toolbar Style

How do I get the new toolbar item style of OSX Yosemite?
I created a standard toolbar, but the buttons don't have that button-like look. Do I need to drag actual buttons to the toolbar to get this look?
What I have:
What I want (that round bezel and white background):
There are two types of items in toolbars, image items and view items. It looks like you have an image item. You seem to want a view item where the view is an NSButton configured as a round textured button. So, yes, you should drag actual buttons to the toolbar.
I would not attempt to control the button background. You should use the button as-is to get the default system appearance. Apple recommends using a PDF template image (all black with the alpha channel used to make the image). The button itself would not have a title/label. Rather that would be on the containing toolbar item.
It looks like you may have applied an internal blue "glow" or highlight to your image. Generally, you should not do that. Let the frameworks apply appropriate effects to the template image automatically based on the button state and shows-state-by mode.
Toolbars in the Human Interface Guidelines
Controls which are appropriate to use in the window frame (including the toolbar)
Designing images for toolbar buttons
Works just fine for my Cocoa app under Yosemite -
are you actually setting the template property for your icon images..?
From the NSImage docs:
The 'template' property is metadata that allows clients to be smarter
about image processing. An image should be marked as a template if it
is basic glpyh-like black and white art that is intended to be
processed into derived images for use on screen.

Recreating the iPad home screen icon rotation / orientation effect

I am creating a grid of icons in Objective C / Xcode.
Is there anyway to re-create the iPad Home screen, the one filled with a grid of icons for each App you have on your iPad.
What I am most interested in is reproducing the effect on the icons when the device is rotated. On rotation, a new grid icons (which matches the new orientation) swings around to the right orientation, and the icons themselves transform (I'm guessing its an alpha fade from one icon to the other) into the new icon that would appear at that position.
Ive looked at this SO question, and also at this blog. But I am wondering if there is a class (hopefully one developed by Apple, but third party solutions will do) which recreates this effect?
If there isn't such a class, can anyone suggest to me how I would do the icon transformation effect whilst the screen is swinging around to the correct orientation?
iOS 6 offers a class called UICollectionView that handles the creation of these grids for you. The API is fairly similar to that of UITableView and allows you lots of control for customization.
Check out the UICollectionView class reference, as well as this introductory tutorial.

Sliding Menu in Mac App

How can I make a sliding menu like (as an example) Sparrow's main email menu?
In the case of Sparrow:
It's a column of buttons that essentially slide to reveal a NSScrollView (with custom NSTableView?) with various folders inside (inbox, sent, etc). Clicking on a different account causes that account to slide up to the top and reveals the various folders inside.
How could I go about doing a menu similar to this?
There is some fairly cool Apple sample code here to deal with table views and animation (uses stuff that is generally only available as of Mac OS X 10.7 however):
https://developer.apple.com/library/mac/#samplecode/AnimatedTableView/Listings/ATPopupWindow_m.html%23//apple_ref/doc/uid/DTS40008863-ATPopupWindow_m-DontLinkElementID_26
Also, for basic window resize animation you can use the setFrame:display:animate: method of NSWindow.

NSOutline/NSTableView source list Lion-style icons

From the Mac OS X HIG:
As with the icons that can be used inside toolbar controls, the system applies various effects to sidebar icons. To help you understand how these effects can change the appearance of a sidebar icon, consider the Finder Home icon, shown here in its unprocessed state[...]
So I'm trying to get my NSOutlineView to render a black sidebar icon with the typical new Lion style. I'm using a view-based NSOutlineView. However, I'm unable to find anything in the docs and if I simple set the imageView.image property to the sidebar image, it renders in black. So I figure there must be some sort of opt-in mechanism to get the sidebar to render it properly. Any suggestions on how to achieve that?
Apart from using the setTemplate: method of NSImage, you can just rename your images. This is from the documentation of imageNamed:…
If an application is linked in Mac OS X v10.5 or later, images
requested using this method and whose name ends in the word “Template”
are automatically marked as template images.