Custom UIButton iphone - iphone

I want to change the color of my UIButton. I did this:
UIButton *alreadySubscriber = [[UIButton alloc] initWithFrame:CGRectMake(12, maxy-65, 262.0, 50)];
alreadySubscriber.layer.cornerRadius = 10.0f;
[alreadySubscriber setBackgroundColor:[UIColor orangeColor]];
[alreadySubscriber setTitle:#"Already a subscriber" forState:UIControlStateNormal];
The color of the button changes, but no longer see the effect of bright light booby top. how can I fix this?

We're unable to programmatically set this 'bubble effect' for the UIButton I'm afraid. The only way to go about it far as I can tell is to go for a custom button with an image (or two images for the normal and active states).
The resource Eugene put up earlier seems pretty good in fact.

I don't really know what kind of booby light are you talking about, but have you tried using images for your buttons? I'd suggest using two different images like those you can create here http://dabuttonfactory.com/.

You should create as a custom button and add the image/color as background.

Related

specially indicating or highlighting a toolbar button when a note is added in iphone

In my app i have an option for adding notes to particular tips.the button for adding notes is at the top.So i want to highlight that particular button when a notes is added.If a Tip has a note attached the notes icon should light up / glow (somehow look different), so that it can quickly identify this tip has a note attached.How can i implement this one.Is it possible.Can any one Please help me.Thanks in advance
We used some special button in tool bar in an application. We make it following way.
UIButton* btnInfo = [UIButton buttonWithType:UIButtonTypeInfoLight];
[btnInfo addTarget:self action:#selector(verInfoBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:btnInfo];
Here main point is to use [[UIBarButtonItem alloc] initWithCustomView:btnInfo]; method.
Check if it can be helpful...

Which UI object to do this?

I have seen many times waiting panels (panels with a uiactivityindicatorview) black/dark with some transparency and white labels.
Like this one :
I guess it is a standard element.
Where can I find it?
Try This. it's the best solution I came across to show the activity. MBProgressHUD
MBProgressHUD looks nice. You might want to check out http://code.google.com/p/toast-notifications-ios/ too.
There's no iOS component that does this.
If you don't want to include an external library just for this one component then you can do it using UI components.
/* Warning, typed from memory */
// Create the UIView that's the background
UIView *pleaseWaitView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
[pleaseWaitView setBackgroundColor:[UIColor colorWithWhite:0.5 alpha:0.5]];
[[pleaseWaitView layer] setCornerRadius:5.0f];
// And create an activity indicator
UIActivityIndicator *i = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[i startAnimating];
[pleaseWaitView addSubview:i];
[i release];
// Add it to the main view (in the middle)
[pleaseWaitView setCenter:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)];
[self.view addSubview:pleaseWaitView];
You can add a UILabel with whatever text you want (in your case, 'Authenticating') in the same way as you added the activity indicator.
The tricky part is setting the corner radius - you will probably need this at the top of your .m file :
#import <QuartzCore/QuartzCore.h>
NB You can do this in interface builder as well if you want (apart from the corner radius bit!) ;)
I answered a question that included an overlay like this. I included the code and the overlay image you need to do it with. Take a look at this answer and take a look at the screen shot it created. I use this overlay as I send email in the background so you will want to edit the code to do your function but the overlay code is already in place.
Locking the Fields in MFMailComposeViewController
Happy Coding!
Check out DSActivityView. I've successfully used it in a few of my projects.
As by now there is no standard UIElement for that in iOS.
But checkout this library:

How to make UISlider's "track" invisible?

I'm trying to emulate Apple's "Slide to Unlock" feature in my application. I get to this point (image below), but as you can see the UISlider's "track" is visible and is covering up my text. Is there a way to change an attribute programmatically that will make the "track" invisible?
Please let me know if you need any of my code.
Thanks in advance!
EDIT: If I change the slider's alpha to 0, it gets rid of my sliding button, so doing that won't work unless I'm doing it wrong. :)
here's an even easier way. No need to create images, just instantiate an empty UIImage class :P
UIImage *clearImage = [[UIImage alloc] init];
[self.slider setMinimumTrackImage:clearImage forState:UIControlStateNormal];
[self.slider setMaximumTrackImage:clearImage forState:UIControlStateNormal];
Actually I just figured it out. Here's what I did:
UIImage *sliderMinimum = [[UIImage imageNamed:#"clearTrack.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
[slider setMinimumTrackImage:sliderMinimum forState:UIControlStateNormal];
UIImage *sliderMaximum = [[UIImage imageNamed:#"clearTrack.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
[slider setMaximumTrackImage:sliderMaximum forState:UIControlStateNormal];
clearTrack.png is just a clear slider image I made.
Now I have this: yay!
There probably isn't a way to hide the track; the "slide to unlock" doesn't behave like a UISlider and is probably a custom control. You might be able to hack the slider control, maybe by setting opacity low (0 will make it hidden and it won't receive touches), but if you go that route you will probably have something break after an OS update. Apple doesn't bend over backwards for compatibility like Microsoft does.
The right way to do this is with a custom control. It may seem like more work than using a UISlider, but it's not if you compare it against all the time you have spent and/or will spend hacking a UISlider.
To do it: subclass UIControl. Write your own drawing code to make it look right (you can probably reuse some of whatever you are doing now). Then register for touch events to move the slider handle:
UIControlEventTouchDown: if it's on the handle, set a "moving" flag
UIControlEventTouchDragInside: if the moving flag is set, move the handle to the touch position; you can just update an instance variable, call setNeedsDisplay to draw it in the new position.
UIControlEventTouchUpInside: if moving flag is set, and handle is at end, unlock
If you want to mimic the real unlock handle, play around with it and see how it behaves. You might need to respond to the events differently (what happens if you drag outside the slider path). But you should be able to get the gist of it.
In Swift:
slider.setMinimumTrackImage(UIImage(), forState: .Normal)
slider.setMaximumTrackImage(UIImage(), forState: .Normal)
In answer to the stated question, you can set a transparent 1px png for the minimum and maximum track images.
Looks like just setting the tint color to clear does it...
[slider setMinimumTrackTintColor:[UIColor clearColor]];
[slider setMaximumTrackTintColor:[UIColor clearColor]];
Answer by #Arjay Waran is the best in my opinion.
Heres the Swift 3.0 Version of it.
slider.minimumTrackTintColor = UIColor.clear
slider.maximumTrackTintColor = UIColor.clear
Cheers
From Story Board:-
select clear color for Min Track and Max Track

Inverting UIBarButtonItem "Play" for use as a Back Button?

Okay, simple enough.
I'm coding up a simple web view, and I'm providing a few Safari-like controls for navigation.
Play seems to be the obvious choice for the forward button, but I'd like to have a Back Button as well, as seen in several Apple and third party apps.
Is there a way to invert the icon, so that it points backwards, or are all the apps using this setup using images to replicate this functionality?
Unicode is your friend here.
Create a UIBarButtonItem (in Interface Builder or in code) and set it to "Custom" where you can enter text for the button.
Now use these Unicode characters to simulate the back & forward buttons:
◄ and ►
I use it in my apps and it looks great.
I know this was answered long ago, however just to add...
Yes, you can use Unicode but it does not look the same as the standard ios button. And if you have strict requirements to match ios look than you will need to at least make an image for the back button, in this case by simply downloading the play image and flipping it.
UIImage *image = [UIImage imageNamed:#"backButton.png"];
UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
[btnBack setImage:image forState:UIControlStateNormal];
btnBack.frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
UIBarButtonItem * btnItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];
[btnItem addTarget:self action:#selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
// add it to your bar
self.navigationItem.leftBarButtonItem = btnItem;
(wrote it without spell checking... so beware of spelling errors that may have resulted)
// button images are here.
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html
You could use atPeek to extract the play button png from an app that uses it, and then use any image manipulation program to flip it.

iPhone + UIControls

It is a very generic question (not related to any application). Just my quest to know more.
While creating any iPhone application, we see that there few UIControls available in Library of Interface Builder. Using those we can create all basic application and designs, and also we can't customize those to much extent
But if we see on App Store, thousands of applications are available, where there many UIControls which are either not available in Library or might be they customized to much extent.
I want to know that:
Can we use controls other than available in Library (if yes than how and from where to get that).
If we can't than how do we modify (customize) the available UIControls to such an extent that they look totally different from their original primary look.
Regards,
Pratik
For a start, it is possible to set an image (including transparency) for most controllers. Many controller that look like different controls may actually be the same controls, just reskinned. Many controllers allow subviews - it is amazing how much can be achieved just using the table controller.
It is also worth knowing that any control you place using the GUI can also be set to a subclass where you override behaviour. Simply select the control, hit Shift-Apple i and change the class in Class Identity.
For customised controllers you can check the Three20 Project by Joe Hewitt.
take a look at the three20 library. It include custom styled button, labels and text. It should give you the general idea, how to customize your own UI elements.
Often, you don't use images like casebash mentioned, instead your drawing your elements with graphical methods.
Another possible solution is to override your
- (void)drawRect:(CGRect)rect
of your UIView
Edit:
Source Code taken from
Custom UIButton for Iphone
INDEX_OFFSET = 82753; // random
UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[sampleButton setFrame:CGRectMake(kLeftMargin, 10, self.view.bounds.size.width - kLeftMargin - kRightMargin, 52)];
[sampleButton setTitle:#"Button Title" forState:UIControlStateNormal];
[sampleButton setFont:[UIFont boldSystemFontOfSize:20]];
[sampleButton setTag:<INDEX>+INDEX_OFFSET];
[sampleButton setBackgroundImage:[[UIImage imageNamed:#"redButton.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
[sampleButton addTarget:self action:#selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:sampleButton];