set border of UITextView ios - uitextview

I have a program:
[textView setFont:[UIFont fontWithName:#"ArialMT" size:20]];
[textView setEditable:NO];
[textView setScrollEnabled:NO];
[textView.layer setMasksToBounds:NO];
[textView.layer setBorderColor: [[UIColor lightGrayColor] CGColor]];
[textView.layer setBorderWidth:1.0f];
textView.layer.shadowColor = [[UIColor lightGrayColor]CGColor];
textView.layer.shadowOpacity = 1.0f;
textView.layer.shadowRadius = 5.0f;
[textView.layer setShadowOffset:CGSizeMake(2, 2)];
this code set a shadow and border for a UITextView, but how can i set border of textview not include top line , only set border for left, right and bottom line ?

This will do what you want, and it is ridiculously simple to use and integrate: https://github.com/99centsappdevelopment/JSTextView

Related

How can I change color of TextField border? iOS

I can use clear body style in inspector and when I can draw custom lines, but may be there is a more simple way?
Import <QuartzCore/QuartzCore.h>
textField.layer.cornerRadius = 8.0f;
textField.layer.masksToBounds = YES;
textField.layer.borderColor = [[UIColor blueColor]CGColor];
textField.layer.borderWidth = 1.0f;
also add its frameworks^

IOS7 UINavigationBar black background

Does anybody know, how I can make the UINavigationBar solid black in IOS7? Default it is white, and I need it black.
If you're targeting only iOS 7 you can use:
[[UINavigationBar appearance] setBarTintColor:(UIColor *)];
Here is one way that creates a black UIImage programmatically and sets it for the UINavigationBar's appearance:
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)];
background.backgroundColor = [UIColor blackColor];
UIGraphicsBeginImageContext(background.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[background.layer renderInContext:context];
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
found it by myself. Go into storyboard-designer, select the ViewController, go to attribute inspector and change Top Bar from inferred to 'Opaque black navigation bar'

Rotate a UIImageView according to UIWindow Orientations?

I have a UIImageView in bottom side of UIWindow. I want it to always display it in bottom side whatever the orientation is, but having trouble implementing it. Any Solution for this ?
NSLog(#"rotate");
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
// Rotate 90 degrees to hide it off screen
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform,DegreesToRadians(0));
delegate.imgV.transform = rotationTransform;
}
else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)){
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
// Rotate 90 degrees to hide it off screen
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform,DegreesToRadians(90));
delegate.imgV.transform = rotationTransform;
}
Enjoy :-)

Relative Layout width/height is not work programmatically?

I want to doing a relative layout programmatically and set android:layout_widht=60 android:layout_height=60.When i doing programmatically it is fill all screen? How can i do that?
my code:`
RelativeLayout relativeLayout=new RelativeLayout(getContext());
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rel_btn.height = 60;
rel_btn.width = 60;
relativeLayout.setLayoutParams(rel_btn);
this.setBackgroundResource(com.example.R.drawable.line);`
screen:
btn.getLayoutParams().width = width;
btn.getLayoutParams().height = height;
in fact, just use
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
60, 60);
that's OK. the problem maybe the background pic stretch the button

how can I set contentoffset and change the height of UIScrollview at same time

I'm trying to scroll up my UISCrollView when the keyboard is shown
I use setContentOffset to shift the uiview up.
At the same time I want to decrease the height of my UISCrollView to (view height - keyboard height), so that the entire content view can be scrolled.
I apply both the changes in keyboardWillShow notification
When I actually bring the keyboard up in my app, the contents first get pushed up and then they are pushed down (which gives a flickering effect). I'm trying to smooth out both the transformations in one go..
Is it possible?
Code Below ---
- (void) keyboardWillShow {
CGPoint contentOffset = scrollView.contentOffset;
CGRect scrollViewFrame = scrollView.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
if (contentOffset.y >= 0 && contentOffset.x >= 0) {
isContentOffset = YES;
contentOffset.y += screenShift;
[scrollView setContentOffset:contentOffset animated: NO];
}
scrollViewFrame.size.height = keyboardOrigin.y - self.view.frame.origin.y - toolbarHeight;
scrollView.frame = scrollViewFrame;
[UIView commitAnimations];
}
There is an option for animation when you setContentOffset for animation. here is the code that i use all the time
- (void)textViewDidBeginEditing:(UITextView *)textView
{
svos = scrollView.contentOffset;
CGRect rect = [textView bounds];
rect = [textView convertRect:rect toView:self.scrollView];
CGPoint point = rect.origin ;
point.x = 0 ;
[self.scrollView setContentOffset:point animated:YES];
doneButton.enabled = YES;
}
- (IBAction)donePressed
{
[scrollView setContentOffset:svos animated:YES];
[textview resignFirstResponder];
doneButton.enabled = NO;
}
It works fine for me.
Are you wrapping these changes in an animation block?
[UIView beginAnimations:#"resizeScroll" context:nil];
// make your changes to set and content offset
[UIView commitAnimations];
I think I have got a solution for this. You can handle the resize of the view in textViewDidBeginEditing method. You can just change the frame size of the scrollView to half by
CGRect tframe = myscrollView.frame;
tframe.size.height/=2;
myscrollView.frame = tframe;
and to initialize or handle the total length of the scrollview you can set the contentSize of the scrollView in the similar fashion as the frame was set in above snippet. for example
CGSize tsize = self.view.frame.size;
//here you can change the height and width of the scrollView
myscrollView.contentSize = tsize;
I hope this should do the trick for you. If it does please communicate.
Figured out the issue...
When the keyboard button was clicked, I was doing a becomeFirstResponder followed by a resignFirstResponder on keyboard view. This caused keyboardWillShow followed by keyboardWillHide and another keyboardWillShow notification, which brought the keyboard up, brought it back down and then up again.
Thanks to everybody who tried to help out.. and sorry the issue was pretty different...

Resources