Minimimtrackimage alignment issues in swift - ios

I’m trying to create a waveform player similar to soundcloud, the minimum track image I set for the slider originally kept stretching to the slider button itself. I wanted it perfectly aligned with the maximumtrackimage so I users the code:
Image.ResizableImage(withCapInsets:UIEdgeInsets:0,0,0,0)
Screen shot
Which made the image stretch out past the slider button to the whole slider track itself, which is what I wanted but the problem is that the image is passing the slider track and I want it to resize from the beginning of the slider track to the end.

I can't quite remember what the SoundCloud interface looks like, but I seem to recall it's something like this:
I generated that effect easily without using any slider. In general it's probably best to do things the easy way, constructing your own interface rather than trying to bend some existing interface element (such as your slider) to some purpose for which it was never intended.
My interface consists of two image views, a red version of the sound "wave" with a black version laid on top of it. The "transition" from black to red is performed by sliding a layer mask sideways over the black version of the image view, thus revealing the red version which was hidden behind it.
So all you would have to do is coordinate the position of the layer mask with the position being played within the song. If you wanted to use this as a scrubber, you would just detect the user's finger within the image view and do the same thing.

Related

Custom UISlider with pips ios

Wondering if the above can be created using UISlider? If not, what other ways can this be accomplished?
You can set components of a UISlider, such as the currentThumbImage ( see: "Appearance of Sliders"1).
However, it is almost certainly easier to just re-implement a slider for this much customization. Simply use background UIImageView with the scale image, and then add a separate UIView (or UIImageView) for the arrow. Finally, attach a UIPanGestureRecognizer to the arrow view to allow a user translate the view vertically.
You can change a lot in the appearance of a UISlider like setting the thumb to a red arrow. You can also replace the background image with the inches ruler and with different rulers for the different device types and display sizes.
The one thing that I don't see is that you turn the slider to work vertically. I know them only working left to right.
If I'm right, your only chance is to have a ruler as background image and a view that contains the arrow and a label with the actual value. That whole view can be pawned and tapped using Gesture Listener.

Creating an animation such as iOS 8 Weather App

I want to create a view in which I like to have animation such as the one present in iOS 8 Weather app.
I try to explain more what I have done. If anything is incorrect please guide me.
In the top I put a label for the temperature. (The big one)
Below that label, I put another label to show some text. In the Weather app, there is the horizontal scrollview showing the hourly forecast.
Next is the Table view.
What I want to achieve is that when I start scrolling, the first label disappear smoothly and the second one go to top of the screen and the TableView stretches to show more content.
When I scroll back to the top, I want the whole process to revert.
What is the best way to do this?
I've recently re-created the iOS8 Weather app's scrolling effect for an app I'm creating.
The complete code is too long to post here but for anyone who's interested, I've put it on GitHub. You can download and run the project to see how it looks. Improvements to the code are welcome:
UIScrollView with masked content.
It works like this:
You have one scrollview (the size of the screen), which contains a subview (the mask) which in turn has a subview (the content). We also add a large label to the top of the screen (in the Weather app, this displays the temperature).
Then you use the scrollViewDidScroll delegate method to keep the mask fixed to the screen as the user scrolls. You also use this method to stretch the mask upwards at first.
Fixing the mask to the screen means that the mask's subviews (our content) also becomes fixed. But we want it to scroll, so we do the opposite to the content of what we did to the mask (again, using scrollViewDidScroll).
We need the mask to actually behave as a mask, so we set clipsToBounds = YES on the mask.
Finally, we use the scrollview's offset during scroll to move and fade the big label at the top of the screen.
To make it behave exactly like the iOS8 Weather app, we need to also do the following:
Cancel any scroll touches that happen above the mask, i.e. over the large temperature display.
Ensure that the initial scroll that moves the temperature display is completed programatically if the user doesn't complete it.
Add a sideways-scrolling subview which is anchored to the top of the mask.
I haven't done these yet, though.

Masked scrollable button list

I want to implement scrollable button list which are displayed inside popup. I would need some kind of masking, but buttons should also work inside mask. Any suggestions how to do it?
It is possible to achieve this with CCMask class but this is pretty slow way to do it as mask has to be applied every update.
If you use this class you will also loose button detection so you will have to play with touch detection. You will also nead a lot of tweaks to position mask & objects exactly where you want.
When you will finish everything it will not be as good as you thought it will be .. The feeling of scrolling will just not be OK, since there will be masking lag ...
It is better to hide hidden parts of scrollable items with some kind of "window" images

View hidden part of scrollviewer in Windows Phone 7

I'm creating a WP7 application to crop photo, then add some effects and upload to server. I want when users choose which area of photo will be cropped, they can see the remain part.
I have my photo contained in a scrollviewer, so users can scroll to position they want, and crop the visible part of photo.
However, when scrolling in scrollviewer, the hidden part of photo is totally transparent, it make users hard to figure. I want users can view invisible part with opacity about 50%.
This image can explain more clear:
Is there a workaround or another control to solve this problem?
Thank you !
Rather than using cropping I'd try layering something over the top to create the semi-transparency.
Cropping means don't show this part of the image. It isn't just temporarily hiding it.

Fade UIImageView as it approaches the edges of a UIScrollView

I have a UIScrollView over an image at the bottom of my app that acts as a dock with icons that can be scrolled through horizontally. Instead of the harsh edges of the UIScrollView, I would like the icons to fade out for a more aesthetically pleasing look. Being new to iOS development, I don't know if either of these would be valid options:
Create a faded image to use as an overlay on the scrollview so the
icons only appear through the visible portion.
Actually change the
alpha of the images based on their distance from the center (or from
each edge).
I suspect the first idea would be the most simple, but I'd like to throw this out there for any other ideas.
Note: I did see this tutorial, however that technique assumes that the background is a solid color. If I were to do it programatically, I would probably need to fade the individual images.
You can definitely implement something along the lines of #2. It'd be something similar to what the tutorial describes. The alpha transition however won't be as smooth as using the gradient layer mentioned in the tutorial or using an image since the entire icon would have the same alpha. How much discernible the difference is depends on the size of your icons. Smaller icons, very few will be able to tell the difference. Larger icons the difference would be quite clear.
You'd have to implement the
(void)scrollViewDidScroll:(UIScrollView *)scrollView
method in your scroll view's delegate class. This method will get called every time the scroll view changes the location of its content. In this method you can call its subviews and adjust their alphas as required. To optimize it a bit instead of calling the alpha adjustments on all the elements you can just update the subviews which are still partially/completely visible.
EDIT: to figure out which views to adjust you'll use the contentOffset property of the scrollView that gets passed as a parameter in the above method.

Resources