Progresshud without rounded corner background view - ios

I want to remove background view for mbprogresshud. I am trying set color and background color of bezelView to clear color, but its not showing what i exactly wanted. Is there any way to remove background view from hud. My code is like this
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
[hud.bezelView setColor:kColorMainParentColor];
[hud.bezelView setBackgroundColor:kColorMainParentColor];
[hud.bezelView setStyle:MBProgressHUDBackgroundStyleBlur];
[hud setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.2]];

Find this line bezelView.layer.cornerRadius = 5.f; from MBProgressHUD.m file and delete or comment it out.

Related

UIActivityIndicatorView not appearing in Subview

So previously in my application, I had an UIActivityIndicatorView for processes that let the User know that something is loading. I wanted to add a layer of text to inform the user such as signing up,retrieving data, etc. I created a UIView, set it's frame to be in the center of the screen, than my hope was to create the UIActivityIndicatorView in the center and the UILabel in the bottom fourth. My label appears as planned, however now my UIActivityIndicatorView does not appear anymore so I'm curious to as why. I have made sure that the UIActivityIndicatorView is white so it's visible against the black background color and checked other common pitfalls. It seems I'm not understanding something and I was curious if someone could point me in the right direction. Thanks
/*Create the UIView that will serve as the frame to our label and activity view*/
UIView *indicatorFrame=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-50, (self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height-self.tabBarController.tabBar.frame.size.height)/2.0-50, 100, 100)];
indicatorFrame.backgroundColor=[UIColor blackColor];
indicatorFrame.layer.borderColor=[[UIColor whiteColor]CGColor];
indicatorFrame.layer.borderWidth=2.0f;
indicatorFrame.layer.cornerRadius=10.0f;
indicatorFrame.layer.masksToBounds=YES;
[self.view addSubview:indicatorFrame];
/*Create activity indicator*/
UIActivityIndicatorView *spinner=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(indicatorFrame.frame.size.width/2.0,indicatorFrame.frame
.size.height/2)];
[indicatorFrame addSubview:spinner];
/*Create Text Label to be added to the indicatorFrame*/
UILabel *indicatorViewText=[[UILabel alloc]initWithFrame:CGRectMake(5,indicatorFrame.frame.size.height/2,indicatorFrame.frame.size.width-5,30)];
[indicatorViewText setCenter:CGPointMake(indicatorFrame.frame.size.width/2,(indicatorFrame.frame.size.height)*3/4)];
indicatorViewText.text=#"Logging In";
indicatorViewText.font=[UIFont fontWithName:#"Georgia" size:18];
indicatorViewText.numberOfLines=1;
indicatorViewText.textColor=[UIColor whiteColor];
indicatorViewText.textAlignment=NSTextAlignmentCenter;
indicatorViewText.adjustsFontSizeToFitWidth=YES;
[indicatorFrame addSubview:indicatorViewText];
[spinner startAnimating];
Tried your code and it works without a problem. Your problem could be somewhere else in the rest of your view controller.
Your codes' output http://i.imgur.com/6i5zxBP.png
However, the only change i did is to make the text visible by settings its background color to clear color.
My personal opinion however, is to use a library like MBProgressHUD or JGProgressHUD. They cut down your code drastically and you do not have to worry about these kind of problems.

Toast Message in ios with multiline

I Am looking for a Toast Message Library such as MBProgressHUD, which contains loading screen with message and without, detail text and only text message.
But MBProgressHUD not have the support for multiline toast message only in showing text message
Can anyone suggest me a Library.
Thanks in advance.
Please use detailsLabelText property of MBProgressHUD. It supports multiline text.
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.detailsLabelText = #"Your multiline text here ......."
hud.removeFromSuperViewOnHide = YES;
hud.margin = 10.f;
[hud hide:YES afterDelay:2];
This library does what you need DCToastView allowing you to provide toast messages from the top or bottom side of the screen using auto layout and stackviews it renders as many lines as you need:
You will just need to add the pod
pod 'DCToastView'
Import it where you want to use it.
import DCToastView
And use it
ToastPresenter.shared.show(in: self.view, message: "This is a toast")
You can pass the following properties to the show method:
view: The view in which the toast is going to be presented
message: The message that the toast will show
toastPlace: The place which can be .down or .up
backgroundColor: The background color of the toast; defaults to black
textColor: The text color of the message; defaults to white
timeOut: The amount of seconds for the toast to dismiss if not provided it means that the toast will be sticky (will remain until touched); defaults to nil
roundness: How round the toast will be: .none, .low, .mid, .high; defaults to .mid
This is something, which was needed by you. Created with lot of Animation Options, screen positions, and duration. Even you can provide your own duration. Check that out below.
AVIToast Link
ToastThis Supports Multiline toasts.
I'm able to display multiline messages with MBProgressHUD using this code:
MBProgressHUD *h = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
h.mode = MBProgressHUDModeText;
h.labelText = n.userInfo[#"message"];
h.labelFont = [UIFont boldSystemFontOfSize:12];
[h hide:YES afterDelay:1];

NKOColorPickerView: Get updated color

I am using a library called NKOColorPickerView (https://github.com/FWCarlos/NKO-Color-Picker-View-iOS)
The the library gives the following method to identify If the color has been changed from palette.
NKOColorPickerDidChangeColorBlock colorDidChangeBlock = ^(UIColor *color){
//Your code handling a color change in the picker view.
};
I was wondering If it is possible to get the color which is currently selected. I have an imageView on my storyboard and I would like to change the background color of the storyboard to the selected color in the palette.
I tried the following code, but It doesn't work. Please help me. I am newbie.
[imageView setBackgroundColor:[UIColor
NKOColorPickerDidChangeColorBlock:colorDidChangeBlock]];
This work do the trick:
[imageView setBackgroundColor:color];
Uhm, you are supposed to add a block callback to the didChangeColorBlock property, and handle color change from it.
__weak __block __typeof(self) weakSelf = self;
colorPicker.didChangeColorBlock = ^(UIColor *color){
[weakSelf.imageView setBackgroundColor:color];
};
Time to brush up your knowledge about blocks.

UIPopoverController backgroundColor causing flash when shown

I'm using the new (in iOS 7) UIPopoverController.backgroundColor setting in my app to change the color of my popovers as needed, but I'm finding that using this setting is causing a "flash" of color change whenever I open my popovers -- in about half a second it starts from the default of translucent white and fades to the color I choose. This is not desired; it should just be the color I set it to when I open it.
The documentation states:
Use this property to customize the background color of your popover. Changing the value of this property while the popover is visible triggers an animated changeover to the new color. The default value of this property is nil, which corresponds to the default background color.
However, even if I set it when my app opens and don't set it again, it will still flash each time I open any of the popovers.
I'm open to using UIPopoverBackgroundView, but I'm not sure that it allows me to change the background color on-the-fly since it seems to be a static solution for just changing the style of all popovers in an app. Thanks in advance for any suggestions.
Edit (The Code):
When my main view controller is loaded and preparing the rest of the UI (this is one of many popover inits):
fileOptionsController = [[FileOptionsViewController alloc] initWithNibName:#"FileOptionsViewController" bundle:nil];
fileOptionsController.delegate = self;
self.fileOptionsPopoverController = [[UIPopoverController alloc] initWithContentViewController:fileOptionsController];
[popoverControllers addObject:self.fileOptionsPopoverController];
After my popovers are initialized, I'm running this (still in the main init code) for the purpose of testing with a long delay between setting backgroundColor and the interaction (note: changing the alpha has no effect, still happens when set to 1):
for (UIPopoverController *po in popoverControllers) {
[po setBackgroundColor:[UIColor colorWithWhite:0.3f alpha:0.90f]];
}
Then, this is called when the user taps a button to show the popover:
- (void)showPopover:(UIPopoverController *)popover from:(UIButton *)btn {
[popover presentPopoverFromRect:CGRectMake(btn.frame.origin.x + 5.0f, btn.frame.origin.y - 1.0f, btn.frame.size.width, btn.frame.size.height) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}
Pretty straight forward. These are the only relevant places where this or any popover is accessed, except where to dismiss it if it's already showing.
I solved this issue dismissing the popover before changing the backgroundColor and then presenting it again:
[popover dismissPopoverAnimated:NO];
if ([popover respondsToSelector:#selector(backgroundColor)]) {
popover.backgroundColor = [UIColor someColor];
}
[popover setContentViewController:viewController animated:NO];
[popover setPopoverContentSize:CGSizeMake(320.0f, 480.0f) animated:NO];
[popover presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionRight
animated:NO];
Doing so the popover is shown again and you won't see any unwanted transition effect.
Since the documentation says that the backgroundColor will animate it your color so this seems be causing this flash/animation (Apple should have given setBackgroundColor with/without animation).
If you can afford to present the popover without animation, I would suggest you could try to turn off animation when you present it. Like one of these two -
Option 1 -
// last parameter as 'NO'
[popover presentPopoverFromRect:CGRectMake(btn.frame.origin.x + 5.0f, btn.frame.origin.y - 1.0f, btn.frame.size.width, btn.frame.size.height) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionLeft animated:NO]; // Don't animate to present
Option 2 - (use setAnimationsEnabled method of UIView to turn off animation temporarily)
- (void)showPopover:(UIPopoverController *)popover from:(UIButton *)btn {
[UIView setAnimationsEnabled:NO]; // Turn off animation
[popover presentPopoverFromRect:CGRectMake(btn.frame.origin.x + 5.0f, btn.frame.origin.y - 1.0f, btn.frame.size.width, btn.frame.size.height) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
[UIView setAnimationsEnabled:YES]; // Turn back on
}
Logically this should work unless Apple is further hacking this property inside it's sdk.
It would be better if you adding your code... Without code I can just say if your are setting color after view appear, then it will animate to that color. So change background color first and than make popover visible.

How to remove search bar background?

I want to remove search bar background and I have tried the following code in custom search bar subclass:
-(void)didAddSubview:(UIView *)subview
{
if ([subview isKindOfClass:NSClassFromString(#"UISearchBarBackground")])
{
subview.alpha=0;
}
}
every thing ok but when click on search bar or cancel search the background color set to black
any one knows how to remove this background color?
searchbar.barStyle = UIBarStyleBlackTranslucent;
Hope it helps you
I used this code in one of my applications to remove the background and added my own background image
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
UIImageView *searchImage=[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 319.0, 44.0)];
[searchImage setImage:[UIImage imageNamed:#"searchbg.png"]];
[searchBar insertSubview:searchImage atIndex:1];
This may help you.

Resources