nimati / fcalertview Goto Github PK
View Code? Open in Web Editor NEWFCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)
License: MIT License
FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)
License: MIT License
Hi,
This is a proposal to improve this succulent framework!
It would be nice that we can have a title on two lines when it's needed. In my natural language, some words are long, and on iPhone, it's very fast to have something like:
"Réinitialiser votre code..."
Instead of:
"Réinitialiser votre code PIN"
Thank you!
Please add support for apps in landscape orientation.
Cocoapods isn't downloading the latest version with doneActionBlock
functionality.
I think it is a tag issue in repo.
Can you make a block version so when you press a button, a block is fired?
For Portrait iPad, the box is really wide. It looks bad.
Hi, this is my code but first a short explanation:
The alert view dismiss on outside touch no matter if I setting "NO" and I need the alert view to dismiss just when the background task have done! I guess this is a mistake in the alertView because the alert view dismiss when should not. Sorry for the english, I hope you can fix it, thank you and have a nice day.
[alert setDismissOnOutsideTouch:NO]; [alert showAlertWithTitle:@"Sending, please wait..." withSubtitle:nil withCustomImage:nil withDoneButtonTitle:nil andButtons:nil]; dispatch_queue_t queue = dispatch_queue_create("My queue", NULL); dispatch_async(queue, ^{ //code to be executed in the background NSLog(@"Inside background task"); [self sendDataToServer:@"POST"]; dispatch_async(dispatch_get_main_queue(), ^{ //code to be executed on the main thread when background task is finished NSLog(@"task done"); [alert dismissAlertView]; });
Hi,
when BounceAnimations is set to False and you use In and Out Animations, the Dismissed event is not called.
Jan
Hello, I am not found titleFont and subtitleFont properties of alert. How can I change font of Title and Subtitle?
Hi there , excellent work.
As a suggestion it would be great if you add font customization capability to the button.
When keyboard is dismissed (textField.resignFirstResponder) the alert is auto-dismissed.
UIViewController is setup to monitor uikeyboard show/hide. I'm animating a button up/down to follow top of uikeyboard using nslayoutconstraint, whose animation requires view.setNeedsLayout and then view.layoutIfNeeded -- maybe that is causing this?
Issue is resolved if I use [alert showAlertInWindow: ...]
Hi - just stumbled upon this and running it through some tests and so far love it! Very good job.
I'm not a good dev can get by - but not good enough to pull, figure out and fix. So if you don't mind I'll just make some suggestion here as I go along and see if they make sense to you.
I like your dark theme - good thinking there. I'm trying a textfield in it and the text is black so it is hard to see in a dark text field.
First of all thank you for this great control. Really love it!
The issue:
I know that the message of the alert should never be nil.
I used FCAlertView to display some error messages coming from a web service. They should never be nil but i forgot to validate them. What came up is in the screenshot below.
I think that you should never ever show something like this to a user. It's 100 times better to present an empty label than showing that to a user.
Now that i saw it, i validate any message and in case it's nil i set some text, however i think you should address this.
Thanks again!
I am using the latest pod version of FCAlertView
The alert view is not showing for me, the first few times.
This is the code I use to show the FCAlertView (Method 1):
let alert = FCAlertView() alert.makeAlertTypeWarning() alert.blurBackground = true alert.showAlert(withTitle: nil, withSubtitle: withText.localized, withCustomImage: nil, withDoneButtonTitle: nil, andButtons: nil)
Or this way (Method 2):
let alert = FCAlertView() alert.colorScheme = "#8DCA63".hexColor alert.blurBackground = true alert.dismissOnOutsideTouch = true alert.avoidCustomImageTint = true alert.delegate = self alert.showAlert(withTitle: nil, withSubtitle: "String", withCustomImage: UIImage(named: "image") , withDoneButtonTitle: "String", andButtons: ["String"])
But it only shows when I call it the way I showed above in a certain view controller.
Let's say we have VC1, VC2 and VC3
I call the Method 2 in VC1 and it doesn't show an alert, then I call the Method 1 in VC2 and it doesn't show an alert, then in VC3 I call Method 2 and it shows an alert. After it shows up the first time it shows up on every VC.
Maybe I am doing something stupid or wrong, but I've tried everything and I can't get it to work...
I hope someone haves a solution
The following properties I can't set. Please help me. Thanks.
alert.firstButtonTitleColor = [UIColor blueColor];
alert.secondButtonTitleColor = [UIColor blueColor];
alert.firstButtonBackgroundColor = [UIColor whiteColor];
alert.secondButtonBackgroundColor = [UIColor blackColor];
- (void)addButton:(NSString *)title withActionBlock:(FCActionBlock)action;
- (void)doneActionBlock:(FCActionBlock)action;`
Can you add nullability annotations to action
. Either make it nullable (and handle the case to prevent it getting put inside dictionary or make it [NSNull null]
) or make it nonnull.
Currently this causes error in swift (as it would also in Obj-c):
alert.addButton("OK".localized, withActionBlock: nil)
now FCAlertView has fixed margin and fixed height
defaultSpacing = 105.0f;
defaultHeight = 200.0f;
i want to fix the width and height , can you provide two properties ?
Hello,
I noticed that FCAlertView uses UIButtons to display images in the circular view. This is bad practice. The code below will be a good implementation, and I am also including a feature to allow for a custom tinted view.
- (void) makeAlertTypeWithColor:(UIColor*)color {
self.colorScheme = color;
alertType = @"Custom";
}
UIImageView *alertViewVector;
if (_avoidCustomImageTint && alertType.length == 0) {
alertViewVector = [[UIImageView alloc] init];
alertViewVector.image = vectorImage;
} else {
alertViewVector = [[UIImageView alloc] init];
alertViewVector.image = [vectorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 15.0f,
-15.0f,
30.0f,
30.0f);
alertViewVector.contentMode = UIViewContentModeScaleAspectFit;
alertViewVector.userInteractionEnabled = 0;
alertViewVector.tintColor = _colorScheme;
Hi,
nice work indeed.
I would like to tell you that there is an error in "clickedButtonIndex:(NSInteger)index buttonTitle:(NSString *)title "
always index is 0 for anyone of the two additional buttons......
Can you please take a look and fix it?
Thank you very much
George
Can you add support for UITextView ?
It would be nice if you can add blurry background using
https://github.com/ivoleko/ILTranslucentView
for iOS 7 and UIVisualEffectView
for iOS 8+.
The ILTranslucentView repo has objc and swift code. Unfortunately you won't be add it as a cocoapod dependency since ios7+swift+cocoapods doesn't mix and the guy put the objc files and swift files in same folder so cocoapods gets confused if you try and use only the obj files: ivoleko/ILTranslucentView#20
@https://github.com/nimati/FCAlertView/blob/master/FCAlertView/Classes/FCAlertView.m#L36:
You can do an objective-C version of below code. (I use swift for my project)
if #available(iOS 8.0, *) {
// Use UIVisualEffectView
let tvev = UIVisualEffectView(effect: UIBlurEffect(style: .Dark))
tvev.translatesAutoresizingMaskIntoConstraints = false
_alertBackground.addSubview(tvev)
} else {
//For iOS 7 - Use ILTranslucentView
(self.viewExternal as! ILTranslucentView).translucentAlpha = 1
(self.viewExternal as! ILTranslucentView).translucentStyle = .Black
(self.viewExternal as! ILTranslucentView).translucentTintColor = UIColor.clearColor()
self.viewExternal.backgroundColor = UIColor.clearColor()
}
For some reason, it seems that the FCAlertViewDelegate causes issues in Swift. Although FCAlertView class is imported and recognized, as soon as I try implementing the delegate (or inherit from it) Swift reports that the class FCAlertView is not defined anymore, which makes little sense because FCAlertViewDelegate (which is part of the same class) is properly recognized.
I do have FCAlertView.h in my bridging header file, so that's not the issue, and sadly I cannot use the Swift version of this pod because we are still stuck with Swift 2.2 and our guidelines forbid the use of libraries which are not part of CocoaPods
I have a problem rotating my device with an alert added to the window.
The alert is no longer centered and the background view is no longer the right size.
Same with keyboard opened when having a textField.
How about a setting to control the background opacity? Maybe also background color but I'd like to make the background a bit darker.
How to change button background color for press state?
Whenever I dismiss the FCAlertView, it never appears again.
Hi!
First of all, thank you for that great library.
Please, tell me, how can I add custom view to alert such as UIProgressView and others?
When I adding my custom view as a subview to FCAlertView object it's added to alertBackground, but I want to add it to alert, below title and above buttons. How can I make this?
Thank you.
I have a subtitle
but no title
.
It logs: FCAlertView Warning: Your Alert should have a title and/or subtitle.
incorrectly.
The last object may not be visible on the screen. I.e. keyboard controls. Its better to use the keyWindow here.
Line 1174
Use
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
instead of
UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
I have found your demo has a little bug which maybe not important.when I turn 'Outside Touch' Off and turn 'Hide Done Button' On at the same time,your alertView which showed can't close.
_flatTurquoise = [UIColor colorWithRed:26.0/255.0f green:188.0/255.0f blue:156.0/255.0f alpha:1.0];
@interface UIColor (Extension)
+ (UIColor *) flatTurquoiseColor;
@end
Just a little suggestion... ha~
Did you edit @dogo's https://github.com/dogo/SCLAlertView ? I think you add to bottom
Inspired By SCLAlertView
When do I install pod it gives this error showing in title
I actually sort of have this in my fork already, but I think this library is pretty great and can be expanded even further. One small thing would be for someone to define the scale of the image within the white background.
Some images just look better if they were a bit bigger.
for instance, by default we have:
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 15.0f,
-15.0f,
30.0f,
30.0f);
We could maybe do something like:
size = 30.0f * scale;
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - size/2,
-size/2,
size,
size);
The scale would ideally be a number that defaults to 1 and goes up to 2, because at 2 it is the size of the entire circle.
Just an idea to think about. I write in Swift pretty exclusively, so the above might be sloppy/invalid Objective-C lol, but you get the point.
i was unable to create alert.makeAlertTypeRateHearts()
Value of type 'FCAlertView' has no member 'makeAlertTypeRateHearts'
Any chance you'll be adding this to the pod soon?
Hi,
this is not a issue only a simple comment.
If someone want to use (custom) image without tint color simply change buttonWithType: from UIButtonTypeSystem to UIButtonTypeCustom
See code: FCAlertView.m
line 463:
UIButton *alertViewVector = [UIButton buttonWithType:UIButtonTypeCustom];
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 15.0f,
-15.0f,
30.0f,
30.0f);
[alertViewVector setImage:vectorImage forState:UIControlStateNormal];
alertViewVector.userInteractionEnabled = 0;
//alertViewVector.tintColor = _colorScheme;
Thank you, good job!
When I pass nil for image and nil for title, the gap between the top of the alertbox and first line of text is quite large.
First of all nice Example very cool and much detail functions.
Give it this example only in Objective-C or also in Swift?
Hi again,
I got the last commit of your tool and the issue with the index now is working ok!
Thanks a lot.
But now I get the following warning in Xcode
"/Users/GEOGERAR/Documents/GEOGER IOS7 Apps/ZTEST/TEST/FCAlertView/FCAlertView.h:39:29: Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)"
in FCAlertView.h at delegate
// Delegate
@Property (nonatomic, weak) id delegate;
can you take a look please?
George
Hi and first of all thanks for the great job!
I have a small issue with textfields on my alert view.
Basically what I'm displaying is an alert view with a text field and two buttons : OK
and Cancel
.
My issue here is that the return block in alert.addTextField(withPlaceholder:_, andTextReturn:_)
doesn't tell me which button was pressed, and the delegate seems to be called before the return block, so I can't store the content of the text field in a variable.
Is there any workaround for this?
Thanks!
Thank you for creating this nice control.
Please change device orientation to interface orientation to reflect the current app orientation and not the device. The device may lay down flat on a table but the interface orientation will always be either landscape or portrait.
Thanks.
Line 337
change
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
to
if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
want to add a property to custom button title color
It would be useful to be able to set a default value for the textfield as well as changing other properties.
My Current workaround is updating the properties after a delay.
DISPATCH_AFTER(0.2, {
alert.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
alert.textField.text = text;
});
In my use case, the FCAlertView does not go on top of the keyboard.
I have a similar component that shows a progress circle that is used in exactly the same circumstance, but that goes on top of the keyboard. This is causing issues because whilst the AlertView is operating, the user can still type stuff in keyboard.
I looked at code:
Your code:
- (void) showAlertInView:(UIViewController *)view withTitle:(NSString *)title withSubtitle:(NSString *)subTitle withCustomImage:(UIImage *)image withDoneButtonTitle:(NSString *)done andButtons:(NSArray *)buttons {
[self checkCustomizationValid];
[self safetyCloseCheck];
[view.view.window addSubview:self];
}
I looked at other component's code: https://github.com/AssistoLab/KVNProgress/blob/master/KVNProgress/Classes/KVNProgress.m#L870
- (void)addToWindow
{
self.originalKeyWindow = [UIApplication sharedApplication].keyWindow;
if (!self.progressWindow) {
self.progressWindow = [[UIWindow alloc] initWithFrame:self.originalKeyWindow.frame];
// That code makes the custom UIWindow handle the orientation changes.
// http://stackoverflow.com/a/27091111/2571566
self.progressWindow.rootViewController = [[KVNRotationViewController alloc] init];
}
self.progressWindow.frame = self.originalKeyWindow.frame;
// Since iOS 9.0 set the windowsLevel to UIWindowLevelStatusBar is not working anymore.
// This trick, place the progressWindow on the top.
UIWindow *lastWindow = [[[UIApplication sharedApplication] windows] lastObject];
self.progressWindow.windowLevel = lastWindow.windowLevel + 1;
[self.progressWindow makeKeyAndVisible];
[self addToView:self.progressWindow];
}
KVNProgress
gives us the option to select the view we want the component to be on top of. If we don't select a view, it uses the code above to correctly place the component on top of everything - including the keyboard.
This is the approach to take. Can you please make another method that allows us to provide the view instead of us providing the viewcontroller.
Hi,
first of all thank you for this great job.
Coming to the issue, I can't understand why from outside the library seems like multiple textfield are managed, but inside the code this is not done. Is it something that you're going to manage?
Davide
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.