Overlay images and customize x,y position in the watchOS storyboard - swift

I want to duplicate this design mockup and use it in production.
iOS has Z-hierarchy for arranging on Z axis, but it's greyed out in watchOS. I want to create an overlay of a profile avatar like this Instagram prototype where only half of the avatar is over the main image.
Naturally I would like all profile images from the server to be placed in the small round imagview which goes on top of the photos in the stream.

Figured it out. It takes some tinkering. The group layout overlap option in the Attribute Inspector works as advertised. My case was unique because I not only wanted an overlay but I also wanted only half of the avatar to overlap as in the Instagram prototype.
Set the group layout overlap attribute to the root group since that has to be done or this to work.
Next apply the overlap attribute to the avatar group since it is the group we want to overlap on top of the cat group.
Use bottom insets on the cat group to push the avatar down. Adjust accordingly. Naturally, if you want a 50% overhang the bottom inset value should be half of the avatar height.
The cat group does not need the overlap attribute.
The circular avatar is not a circular Photoshop element. I simply adjusted the radius of the avatar group to make it round.
Note: You'll get a warning from Xcode when using Overlap.
Interface.storyboard: notice: Discouraged Configuration: Overlap layout falls back to vertical when used before watchOS 4.0

Related

Custom Shaped Buttons Unity UI

Hi I am trying to create custom buttons on unity (trapeziums). I successfully created the visible area on Photoshop and imported it as Sprite 2D UI as per the following image:
The issue arises, when I'm trying to select one of the buttons in game, their border overlap each other, since the transparent area is still being considered as part of the clickable button area. How can I remove this?
EDIT:
Practically when I import I want the squared boxes to not be counted with the image. I need the edges of the orange area to be cut flush with that and not the entire area(i.e. including the transparent boxes).
You may achieve this by using Alpha Hit Test Minimum Threshold. Take a look at this nice video tutorial.
There is one extra step that is not shown in the video but mentioned in the comments: you have to change "Mesh Type" to "Full Rect" and not "Tight" as it is.
Hope that helps.
The clickable area is based on the Rect Transform component of the GameObject. Adjust the width and height to the clickable area you want. You may have to crop your image in photoshop accordingly. If you select 'Gizmos' in the editor you can toggle viewing the click region.

How to create bubble chat TableViewCell like in Messenger using XCode's Interface Builder?

I'm currently trying to implement a chat for my application but since I'm new at Swift development I got stuck at the part where I have to create the TableView cells for it. I was able to find 2 png images of "chat bubbles" (one for receiving and one for sending).
I placed them in Assets and loaded them in an ImageView. Now my problem is how can I place a Label inside the ImageView and rescale it depending on how many lines of text are in the Label. The bubble should not exceed 66% of the screen's width.
OK, there are a few considerations:
If you haven’t already, make your asset stretchable (where the corners aren’t stretched, but only the center is) by:
selecting the asset and zoom in so you can better refine the slices;
in the Xcode menu, choose “Editor” » “Show Slicing”;
click on “Start Slicing”:
click on the center “horizontal and vertical stretching” button:
move your guides to where you want them:
now when you add the image view using this new stretchable asset and choose “Content Mode” of “Scale to Fit”, it will scale in such a way that the center is stretched but the edges aren’t:
Also see Xcode documentation “Add a resizable area to an image”.
In your cell, now just add this image view and the label:
defining the label’s leading/trailing/top/bottom constraints to be inset from the edges of the image view;
define the label’s line count to zero;
define the image view’s width to be “>=” the container view width (with a multiplier of 66%);
obviously define your bubble’s appropriate leading/trailing/top/bottom constraints to its superview, too; and
make sure your cell is using automatic cell height.
For the sake of completeness, the other approach is to make an #IBDesignable view where you draw the bubble yourself with a CAShapeLayer whose path is the cgPath of a UIBezierPath. This is what I’ve done in my chat apps. But this stretchable image approach works fine, too.
By the way, if your speaker and listener bubbles are different colors, note that you might want to have flipped renditions of these bubbles for RTL languages.

Unity grid system woes (How to make grid that auto-collapses to column in portrait mode

My problem is very difficult to describe, so hopefully (with the pictures I provide) someone can help me figure this out. If you are confident you can fix it, I'm willing to pay if I have to. I need this fixed.
I cannot for the life of me figure out how to work with the Unity canvas/layout groups. I have a series of canvases that only show one at a time (think of them as screens). Inside each canvas are components (the first one is a graph and timer, and then a data panel and some buttons.
Here is an image of what I'd like each of the panels to look like (only one of these will be open at a time):
Essentially, I just want each sub-canvas (the dark gray boxes) to inhabit ~50% x 50% of the screen, and when the orientation is horizontal/vertical, tile them accordingly.
Each Child panel (the dark gray) only needs to change. The children inside of the panel can stay and scale relative to the parent canvas.
I have tried EVERYTHING, dug through the documentation, and have run out of options.
Have you tried adding a Layout Element to all of those gray panels with a Flexible Width or Height setting? The screenshot below shows how to have two panels that are side by side, both occupying half the width of their container. (Both have a Flexible Width setting of 1.)
The two Panels are children of the Canvas that has a Horizontal Layout group like this:

Image View - Aligning image in centre on all devices on launchscreen

I'm new to iOS development. I'm trying to add logo on launchscreen in centre. I've a background with gradient colour so I've used a png file and stuck it in the background.
Next is logo which I want to centre for all devices.
I've two part questions
1) Is there anyway I can specify the constraints so that it is applicable to all devices? Example specifying top and bottom constraints in % ?
2) If above is not possible then how do I align logo in centre so that it works on all devices? Do I need to apply constraints separately on all devices?
I tried to set the width and height separately for all devices but it modifies dimensions on other devices. Not sure if this approach will work or I'm doping something wrong?
I'm aware that in worst case that I can just create launchscreens with logo in it as png and stick them for each devices separately which will work. I just wanted to know if it can be done with constraints.
Tx
As you suggested I added constraints to align it in centre horizontally and vertically. It seems to be good on one device but on other it's not. Please see images below.
And then how do I change image size?
One device
2nd device
You do have centerY and centerX constraints.
In storyboard, select the imageView that you have already added to your view. Right-clic drag to the main view (full screen view) in the left panel and choose center horizontally, repeat with center vertically.
You will need to also set the width and height constraints of your logo.
ALTERNATIVELY:
You don't need to clic drag, you can add the center constraints in the "add new alignment constraints" tab.
Finally I manage to solve what I Was looking for thanks to all those who helped. It was good learning period, 2 days in total ;)
Step 1: Align image to centre vertically and horizontally.
Step 2: Scale logo to fill the space. Please follow this video which is bang on point what I was looking for.
http://roadfiresoftware.com/2015/04/how-to-scale-an-image-view-based-on-device-size-with-auto-layout-in-interface-builder/

Adding an image to a scrolling text ticker

I have created a ticker for my project which is working fine.
I want to add up a down arrow image within this ticker as per the stock market.
What should i have to do?
Can anyone help me?
Probably you have to create the desired image pixel for pixel and stick it just after the stock ticker text.
If you are familiar with QT, there is side scroller code with even alpha-blending. It is based on scrolling a text pixel by pixel. Then it would be rather non-complex to add icons.
Though the stock ticker text and the corresponding icons need to be contained as a block of pixels, so you have to repaint all those pixel-blocks next to each other on every paintevent or timer-tick.
Here is the source code for the side scroller: Qt - Scrolling the Text in QWidget