Change the width of the indicator in UITextView - ios

I'm facing a strange request by my client.
He want's the indicator inside the UITextField to be thiner. Can i change the indicator width? is this thing even possible?
Thanks,

Yes it is possible to do width of indicator. You can do it by changing the bound text field. You can do it by drawing the rect by CGRectMake(0, 10, 0, 20)];
in given code i am showing indicator in search bar text box.
indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.frame = CGRectMake(Xaxis, searchBar.bounds.origin.y+6, 40.0, 40.0);
if(![pview.subviews containsObject:indicator])
[pview addSubview:indicator];
[pview bringSubviewToFront:indicator];
it is looking like this. this may help u to understand.

Related

Text of textview is overlapping under textview

My question is simple and I think it is possible but I cant find it.
My design is like this
I give corner radius to textview and also set textContainerInset for padding from right and left both side
txtview_msg.textContainerInset = UIEdgeInsetsMake(5, 10, 10, 5)
Now my problem is like for first 2 line and last 2 line my text goes beneath textview so I need some solution for it.
Please help me into this. Thank you
try this code
UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView1;
txtview_msg.leftViewMode = UITextFieldViewModeAlways;
UIView *paddingView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView2;
txtview_msg.rightViewMode = UITextFieldViewModeAlways;
You can create at first a view of same size how much you given, put cornerRadius how much you given in textview now. than create textview viewSize - corner radius. place the textview exactly in middle of view. set the constraints from that view only, than it will work perfect how you want.
check this attached screenshot:

iOS: UIButton doesn't show up

I'm creating a simple button and adding it as a subview to main view. It doesn't show up though.
This is the code for setting it up:
UIButton* contactButton = [[UIButton alloc] init];
contactButton.titleLabel.text = #"Contact Developer";
[contactButton sizeToFit];
[self.view addSubview:contactButton];
NSLog(#"X: %f || Y: %f || Width: %f || Height: %f", contactButton.frame.origin.x, contactButton.frame.origin.y, contactButton.frame.size.width, contactButton.frame.size.height);
As you may have noticed, I placed a bit of debug code at the end to see the position and dimensions of the button. They are: X: 0, Y: 0, Width: 30, Height: 34
This means it should be showing up in the upper left corner but it doesn't. Whats wrong?
One possible reason for this is that you used titleLabeldirectly. Consider using setTitle:forState: method instead.
To be sure, consider setting backgroundColor, as a debug step, to make sure it's appearing.
Edit As others suggested, try using buttonWithType: instead of [[UIButton alloc] init]. I suggest using UIButtonTypeSystem instead of UIButtonTypeCustom.
You should initialise the button using the following:
UIButton* contactButton = [UIButton buttonWithType:UIButtonTypeCustom];
Try constructing your button a different way:
UIButton* contactButton = [UIButton buttonWithType:UIButtonTypeCustom];
contactButton.backgroundColor = [UIColor redColor];
contactButton.titleLabel.text = #"Contact Developer";
[contactButton sizeToFit];
[self.view addSubview:contactButton];
Are you sure that the button it's not being shown?
I think you are setting the title of the button incorrectly and because of the fact that a default UIButton has clear background and white title, it´s not visible if your superview is white too.
Instead of setting:
contactButton.titleLabel.text = #"Contact Developer"
use:
[contactButton setTitle:#"Contact Developer" forState:UIControlStateNormal]
But you can first try to set a backgroundColor to the button, different that the superview, to see if it's added.
Hope it helps!
(Sorry for my english if i have a mistake)

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.

Restrict UIButton titleText frame

I have a custom UIButton that has some text I am setting on it dynamically.
The problem:
If the text gets too large, it will cover up a white arrow that is on the button's image located on the far right here:
When that text gets too large, that white arrow is covered, which I need to avoid.
Example:
Current code:
[self.filterButton setTitle:#"All" forState:UIControlStateNormal];
self.filterButton.titleLabel.adjustsFontSizeToFitWidth = YES;
self.filterButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
self.filterButton.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
[self.filterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
Some approaches I have tried:
Setting the titleText frame to be %0.85 of the buttons frame.
Current code
Tried to code it to where the frame cuts off at a certain point (of the titleText)
Thanks for any guidance
Have you tried setting the titleEdgeInsets rather than the contentEdgeInsets?

How to remove dots in UITextfield?

In iOS, I am using one text field the length of the text field id too long so it is showing dots at the end of the text field. I need to remove the dots. I have used lineBreakMode also.
See the code I'm using.
CGSize maximumSize = CGSizeMake(titleListTxtFld.frame.size.width, 1000); //here 1000 for maximum height u can increase this if u want
CGSize strSize = [titleListTxtFld.text sizeWithFont:titleListTxtFld.font constrainedToSize:maximumSize lineBreakMode:UILineBreakModeClip];
CGRect newframe = CGRectMake(0, 0, strSize.width, strSize.height);
[titleListTxtFld.text drawInRect:newframe
withFont:titleListTxtFld.font
lineBreakMode:UILineBreakModeClip
alignment:UITextAlignmentLeft];
Please anyone help me on this.
Another approach is (Remove dot and clip text to frame)-
your can remove dot from UITextField calling following code
[self.yourTextField becomeFirstResponder];
you can also hide default keyboard [if you use any custom keyboard] using following code
// Hide keyboard for Dial Pad, but show blinking cursor
UIView *dummyKeyboardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
yourTextField.inputView = dummyKeyboardView;
[dummyKeyboardView release];
But I think IlNero's answer is better for you if you want to show all text (does not clip).

Resources