How to create a flat UIActionSheet - ios

Today's trend in apps includes flat designs, and now I am doing an app that follows with this trend. My problem now is how to create a UIAcionSheet that match with my App Screen's flat UI Design. In relation with this, I saw Instagram's action sheet and I found it interesting. I wish to have that design in my app. Anyone knows how to implement this in ios apps? I have provided a screen shot from instagram app.

You can use RDActionSheet from git
https://github.com/reddavis/RDActionSheet
I hope it will help you..!!

yes,
you can use https://github.com/reddavis/RDActionSheet and also u can change image and color of text and background image of action sheet

You can use FlatUIKIT from Git
https://github.com/Grouper/FlatUIKit
Go through the documentation & you will know how to use it. Awesome collection of Flat UI classes.

You can create a subclass CustomActionSheet derived UIActionSheet,
and create a method called CustomUI in it. Design your code here.
use CustomActionSheet like UIActionSheet, except must call method CustomUI of subclass in willPresentActionSheet delegate:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
if ([actionSheet isKindOfClass:[CustomActionSheet class]]) {
CustomActionSheet *sheet = (CustomActionSheet*)actionSheet;
[sheet CustomUI];
}
}

Related

Is there anything like a GLKTableViewController?

I am currently using a GLKView connected to a GLKViewController in my iOS project to animate the background of my app which works fine. Now I introduced a UITableViewController for displaying some list. I also would like to animate the table view's background similar to the other view controllers. But therefore I need something like a GLKTableViewController, but this doesn't exist.
Somebody any ideas ?
Finally I did implement the most important UITableViewController functionalities myself. Basically it's very simple, just implement the following two protocols/interfaces:
UITableViewDelegate
UITableViewDataSource
... with their corresponding implementations in the *.m file.
Hope this helps also other people. Regards.

UIAlertView (or LMAlertView) with two stacked buttons

How can I create an UIAlertView with two stacked button? Instead of two buttons side by side? In my project I also use LMAlertView (GitHub repository) and I thought it would support them, but I can't find a way to obtain that very UIAlertView style.
Currently I create a UIAlertView with this code below:
LMAlertView *applicationUpdateAlert = [[LMAlertView alloc] initWithTitle:alertTitleFromServer
message:alertMessageFromServer
delegate:self
cancelButtonTitle:NC(#"Aggiorna ora")
otherButtonTitles:NC(#"Ricordamelo piĆ¹ tardi"), nil];
[applicationUpdateAlert show]
I don't know if this can be useful for you to better understand but LMAlertView has a property named buttonsShouldStack which I thought it would be useful for me but I can't properly use it, this is the code related to buttonsShouldStack in LMAlertView.m file (direct link):
- (void)setButtonsShouldStack:(BOOL)buttonsShouldStack
{
_buttonsShouldStack = buttonsShouldStack;
if (self.numberOfButtons == 2) {
[self.buttonTableView reloadData];
[self.otherTableView reloadData];
}
}
Thanks
Maybe you can give a try with this library. It has a demo project that cover your needs.
I fixed the problem by "rewriting" the LMAlertView component in order to treat UIAlertView buttons as UITableView's cells and by setting the rowNumber accordingly, if the alert has to show 1, 2 or more buttons. It's not an easy to show solution so I won't share the code here, also because I don't know if it's Apple's-approval safe.
Thanks to everyone!

How to do Tag/Label/Text View?

I want to do something like this view (I don't know even name it) but I don't know where to start to do it the most efficient (the most less amount of code) way.
I want to do this tag/label/text with same functionality like Apple Mail has. Facebook Messenger has almost the same. Is there some official high level public API for that? Where is the best place to start? TextKit? UITextInput? Can you provide me at least abstract algorithm or point me to some inspirational place?
You could do this if the text is going to be a UILable:
Add the QuartsCore framework to your project.
At the top of the .m file of your View Controller put: #import <QuartzCore/QuartzCore.h>
Add this code to the viewDidLoad method:
self.myLabel.layer.backgroundColor = [UIColor blueColor].cgColor; //set the background color
self.myLabel.layer.cornerRadius = 10 //set the corner radius
There some components you can accomplish that:
AMTagListView
HKKTagWriteView
You need to draw the text yourself. Here is an example similar to what you are looking for.
SMTagField
Instead of using addition framework, I recommend UICollectionView to implement Tags. It's less code, less overhead and easy to implement.
Follow this link for implementing:
https://codentrick.com/create-a-tag-flow-layout-with-uicollectionview/
This is how it looks like. Please note it is flexible too, you could integrate according to your logic.
Hope this will help you

Should UIAlertView be subclassed?

I am sure the answer to this is "no" as the documentation is very clear. But I am a little confused. A standard UIAlertView is pretty dull and I want to improve the look and it seems that other apps do it (see the example below).
Another possibility is that they are not subclassed UIAlertViews. In which case, how is this achieved?
The page UIAlertViews states
Appearance of Alert Views
You cannot customize the appearance of alert views.
So how do we get the something like the example shown here?
No, do not subclass it. From the docs:
Subclassing Notes
The UIAlertView class is intended to be used as-is
and does not support subclassing. The view hierarchy for this class is
private and must not be modified.
What you can do though is create a UIView and have it act similar to a UIAlertView. It's isn't very difficult and seems to be what they are doing in your op.
Apple's docs say that you should not subclass it. That means that there are probably internal reasons that would make it difficult to make it work right.
You might or might not be able to make a subclass of UIAlertView work, but you do so at your own risk, and future iOS releases might break you without warning. If you tried to complain Apple would laugh and tell you "I told you so".
Better to create a view that looks and acts like an alert but is your own custom view/view controller. Beware that even this is dangerous, because Apple has been making sweeping changes to the look and feel of it's UI elements recently. If you implement a view controller that looks and acts like a variant of the current alert view, Apple could change that look and/or behavior in the future and your UI app would end up looking odd and outdated. We've been bitten by this sort of thing before.
Rethink your strategy. Why do you need to use an Alert View? Besides having a modal view displayed top-most on your view stack, there's not much else that it does. Instead, subclass UIView or UIViewController to define your own interface, using images and ui elements to give it the style and input functionality as needed.
I usually subclass UIView, and attach it to the app's window's view so that I'm certain that it will be displayed on top of anything else. And you can use blocks to provide hooks into the various input elements of your new view (did user press OK, or did user enter text?)
For example:
// Instantiate your custom alert
UIView *myCustomAlert = [[UIMyCustomUIViewAlert alloc] initWithFrame:CGRectMake(...)];
// Suppose the new custom alert has a completion block for when user clicks on some button
// Or performs some action...
myCustomAlert.someEventHandler = ^{
// This block should be invoked internally by the custom alert view
// in response to some given user action.
};
// Display your custom alert view
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window addSubview: myCustomAlert];
// Make sure that your custom alert view is top-most
[window bringSubviewToFront: myCustomAlert];
Using this method, however, will not pause the thread's execution like UIAlertView does. Using this method, everything will continue running as usual. So if you need to pause execution while your custom alert is showing, then it gets much trickier.
But otherwise, creating your own custom alerts is quite straightforward, just as you would customize any other view. You could even use Interface Builder.
Hope this helps.
No. You absolutely should not subclass a UIAlertView for any reason. Apple explicitly states this in their documentation (see "Subclassing Notes"). They even tell you that it relies on private methods - and we all know that meddling in private methods in an AppStore app is immediate grounds for rejection.
HOWEVER, there isn't a need to subclass UIAlertView on iOS 7. Apple introduced a new Custom ViewController Transitions feature in iOS 7.0 that lets you present completely custom ViewControllers with completely custom transitions. In other words, you could very easily make your own UIAlertView or even something better. There's a nice tutorial on the new feature here:
In fact, there are lots of good tutorials on this - a quick Google search on the topic turns up a huge wealth of information.

Example of how to customize UIActivityViewController share menu?

Is there an example of how to customize UIActivityViewController share menu with my own icon and IBAction?
I have seen this...
- (id)initWithActivityItems:(NSArray *)activityItems applicationActivities:(NSArray *)applicationActivities;
but I have not gotten it to work yet.
You first need to subclass UIActivity.
Then you need to override certain methods, including activityImage for setting the icon and performActivity for performing the action (what you call "IBAction" in your question).
If instead of performing the action silently, you first need further user interaction and info for your custom activity (e.g., like the Twitter post for the standard UIActivity), you should override activityViewController rather than performActivity.
After you have subclassed UIActivity (as, e.g, MyActivity), you should create an instance of MyActivity and make it an element of the applicationActivities array that you pass to initWithActivityItems:applicationActivities:.
Have a look at the documentation for UIActivity for exactly what you need to override when subclassing and for icon requirements.
Hope this helps a little.

Resources