iOS: Working with custom ui elements - ios

I'd like to use some custom UI elements for an app I'm writing. They're all encased in a .psd in separate layers. Once I isolate them, what's the best way to use them in my app? I've been looking for a tutorial but I can't find anything.
I.e. for a UIToolbar, do I add it as a subview?
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(titleToolbar.frame.origin.x,
titleToolbar.frame.origin.y, titleToolbar.frame.size.width,
titleToolbar.frame.size.height)];
imgView.image = [UIImage imageNamed:#"toolbar1"];
[titleToolbar addSubview:imgView];
For a UIButton, do I just add it as the background image? Should I be subclassing things?
Forgive my ignorance :(

The best thing what you should do, is subclassing, and make universal components. Then like you did, add from code, and add as subviews.

Related

Animated Background

I am making an app in which there are two buttons in the center. The background is there and I need the background to have an animation. With that said I mean like little raindrops constantly falling in the background. I have no clue on how to do this. My customer really, really wants this. Thanks!
Make sure the images are named in numerical order with the number at the end of the name. Then drag and drop the file of images into your Xcode folder area. Then you reference only the image name and not the number in animatedImageNamed.
You need to create an ImageView the size of the Background for each device you plan on using.
//place this in your viewDidLoad
UIImageView * background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 55)];
UIImage * image = [UIImage animatedImageNamed:#"MovingCar" duration:3.6];
background.image = image;
[self.view setBackgroundView: background];
You can change the duration to suit your needs accordingly.
You could use the UIView method animateWithDuration:animations: or one of it's variants that has a completion method to animate images from the top to the bottom of the screen. Take a look at the Xcode docs on that method, and search the web for examples.
As the other poster says, this site is for helping people with problems, not for asking others to provide you with ready-made solutions.
I could bang out some animation code for you that would create an endless stream of falling raindrops, but it would probably take me a couple of hours to get it fully working, and I'd have to charge you for it. (Plus I'm not very familiar with Swift so I'd have to do some translation from Objective-C, which is my day-to-day programming language.)

Add a custom image to UIRefreshControl [duplicate]

I have been looking around but couldn't find anything good about this.
I would like to customize the default UIRefeshControl with different loader, etc. So far I can only change tintColor & attributedTitle properties and most code I found are just basically creating a new "pulltorefresh" effect but what I want is to just use the UIRefreshControl and customize it a bit.
Is this possible?
You can't add different loader without accessing private APIs, but you can add background image:
UIImageView *rcImageView =
[[UIImageView alloc] initWithImage:
[UIImage imageNamed: #"refreshControl.png"]];
[self.refreshControl insertSubview:rcImageView atIndex:0];
assuming self is an instance of UITableViewController subclass.
Image size you need is 320x43px (#2x 640x86px), the middle area (approximately 35px) will be covered by the loader animation.
I show application logo there...

How to customize UIRefreshControl with different image and position?

I have been looking around but couldn't find anything good about this.
I would like to customize the default UIRefeshControl with different loader, etc. So far I can only change tintColor & attributedTitle properties and most code I found are just basically creating a new "pulltorefresh" effect but what I want is to just use the UIRefreshControl and customize it a bit.
Is this possible?
You can't add different loader without accessing private APIs, but you can add background image:
UIImageView *rcImageView =
[[UIImageView alloc] initWithImage:
[UIImage imageNamed: #"refreshControl.png"]];
[self.refreshControl insertSubview:rcImageView atIndex:0];
assuming self is an instance of UITableViewController subclass.
Image size you need is 320x43px (#2x 640x86px), the middle area (approximately 35px) will be covered by the loader animation.
I show application logo there...

Place two UIImages in one UIScrollView

I was tasked to create a image viewer just like IKEA's catalogue viewer. It's completely out of my skills but after all I must try it.
I was once able to create photo viewer with UIScrollView like iPhone's Photo App, but IKEA's catalogue app is far more complicated as it has different parts per catalogue (title page, spread pages, back cover page). It cannot be done by my photo viewer code since it only requires simple array of UIImages. I have to separate them in several parts.
To achieve that, first I have to look for the way to put two UIImages into one UIScrollView, to make those two pages as one spread (two facing pages) zoomable UIScrollView. And our "web service" provides just an array of pages...
Is there any way to achieve this? I have searched around but all of them are the case about "marging" two UIImages, not putting them side by side as one UIImage. Should I have to create one UIImage from two UIImages then put it to the UIScrollView?
I know it's rather simple and noob question, but I really don't know where to start.
Any help would be appreciated.
If you want to make photo viewer then you must refere SDWebImage. This will cache UIIamge with lazy loading. Use it's sample code. It will help you a lot.
All the best !!!
To nest UIImages in the UIScrollView, you should create 2 UIImageViews, figure out the frame dimensions you need, then call [self.scrollView addSubview:myImageView]; for each UIImageView. For example:
UIImage *image1 = [UIImage imageNamed:#"image1"];
UIImage *image2 = [UIImage imageNamed:#"image2"];
UIImageView *imageView1 = [[UIImageView alloc] initWithImage:image1];
// put your specific frame values here
imageView1.frame = CGRectMake(100.0f,100.0f,200.0f,200.0f);
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:image2];
// put your specific frame values here
imageView2.frame = CGRectMake(300.0f,100.0f,200.0f,200.0f);
// This is a property tied to your scrollView, either created in code or in Interface Builder
[self.scrollView addSubview:imageView1];
[self.scrollView addSubview:imageView2];

How to implement an image scrolling mechanism that has magnification and transparency effects?

I want to implement a component like the one in the images below and I want to learn how it's done, but I couldn't search google to find a similar implementation because I couldn't know how to describe this (maybe because English is not my mother tongue).
Can you guys guide me into finding a similar implementation? I already found some coverflow libraries, but this isn't exactly a coverflow implementation. This one magnifies and changes the transparency of the images as the user scrolls.
Thx in advance
if i came to do this i will do like this
add each image to each UIImageView
2.
[imageView1 setAlpha:0.3];
[imageView1 setOpaque:NO];
[imageView2 setAlpha:0.3];
[imageView2 setOpaque:NO];
.........like this do for all of them
or simply put this code in function and pass uiimageview
3.then add all UIImageView objects to view from back.

Resources