IOS notes (common knowledge points)
This is some notes I made when I was working on projects at the company .......
// 1. iphone development-change the color of the dot in UIPageControl
PageControl. currentPageIndicatorTintColor = [UIColor blackColor];
PageControl. pageIndicatorTintColor = [UIColor grayColor];
// 2. How does ios make the status bar white?
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent];
If not, add View controller-based status bar appearance NO in info. plist.
See http://beyondvincent.com/blog/2013/11/03/120-customize-navigation-status-bar-ios-7/
// 3. For example, modify the color and font of the default title "Yiyun miyin" in the navigation bar.
Self. title = @ "Yi Yun meiyin ";
Self. navigationController. navigationBar. titleTextAttributes =@{ UITextAttributeTextColor: [UIColor whiteColor], UITextAttributeFont: [UIFont boldSystemFontOfSize: 20]};
// 4. Set the rounded corner for the label
Label. layer. borderWidth = 1.0f;
Label. layer. cornerRadius = 5.0f;
// 5. The following method must be implemented to manually rotate the status bar
-(BOOL) shouldAutorotate
{
Return NO;
}
-(NSUInteger) supportedInterfaceOrientations
{
Return UIInterfaceOrientationMaskPortrait;
}
// 6. How to set the display to portrait only
Modify supportedInterfaceOrientations in info. plist to set item to portrait. This setting is global.
// 7. Use UIColor to display # convert the traditional color f6f6f6 to 240 in decimal format
UIColor * color = [UIColor colorWithRed: 240/255. 0 green: 240/255. 0 blue: 240/255. 0 alpha: 1];
// 8. Create a category, extension, protocol, and empty file
Cmd + n select the objective-c File-> File Type in ios Source (category, extension, protocol, empty File)
// 9. convert a view to an image
// Convert a view to an image
UIGraphicsBeginImageContext (oppositeImageView. bounds. size );
[OppositeImageView. layer renderInContext: UIGraphicsGetCurrentContext ()];
UIImage * oppositeImg = UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext ();
// 10. Achieve the drag effect of the Image view
-(Void) viewDidLoad {
[Super viewDidLoad];
// Create an image View
ImageView = [[UIImageView alloc] initWithFrame: CGRectMake (100,100,100,150)];
ImageView. userInteractionEnabled = YES;
ImageView. image = [UIImage imageNamed: @ "ad_1"];
// Translation gesture
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget: self action: @ selector (panAction :)];
[ImageView addGestureRecognizer: pan];
[Self. view addSubview: imageView];
}
// Drag event of the translation gesture
-(Void) panAction :( UIPanGestureRecognizer *) pan
{
CGPoint point = [pan translationInView: self. view];
Pan. view. center = CGPointMake (pan. view. center. x + point. x, pan. view. center. y + point. y );
[Pan setTranslation: CGPointZero inView: self. view];
}
// 11. Images can respond to events. For example, you can drag a UITextView to an image.
BackgrondImage. userInteractionEnabled = YES;