“This is my 42nd day of participating in the First Challenge 2022. For more details: First Challenge 2022.”
I Image translation & rotation processing
List of grouped headView image translation, rotation processing
1.1 Image translation processing
#pragmaMark-settransform processing
//Tells the view that its superview changed. Called when the current control loads into the parent control (TableView)
- (void)didMoveToSuperview{
NSLog(@"%s",__func__);
//2. Pan and scroll the image of button's imageView -- first load data, then set pan
CGFloat angle = (self.friendsGroup.isOpen) ? M_PI_2 :0;
[self.titleButtonView.imageView setTransform:CGAffineTransformMakeRotation(angle)];
}
// Set the alignment of the imageView contents and whether to cut out the excess parts
[_titleButtonView.imageView setContentMode:UIViewContentModeCenter];
[_titleButtonView.imageView setClipsToBounds:NO];//subviews are confined to the bounds of the view. Do not cut excess parts
Copy the code
1.2 Stretching processing of images
Handle the size relationship between the background image of the message button ImageView, titleLabel, and button itself
1.3 Picture stretching
To determine the image can be adjusted small rectangular resizableImageWithCapInsets: (make sure to stretch, small rectangular tiled).
Get stretchable image: Identify the small rectangle that fills the “empty area after stretching”
#pragmaMark - Get stretchable picture - identify the small rectangle that fills the "empty area after stretching"
- (UIImage *)resizableImageWithImage:(UIImage *) image{
CGFloat widthForTopORBottom = image.size.width*0.5f - 1;//inset top, bottom
CGFloat heightForLeftORRight = image.size.height*0.5f - 1;// Inset left and right
UIImage *resizableImage = [image resizableImageWithCapInsets:UIEdgeInsetsMake(heightForLeftORRight, widthForTopORBottom, heightForLeftORRight, widthForTopORBottom)];
return resizableImage;
}
Copy the code
II Other related knowledge points
2.1 Keyboard Processing
[center addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];// Listen for keyboard notifications
#pragmaProxy method for mark-ScrollView
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
NSLog(@"%s",__func__);
// Close the keyboard
[self.view endEditing:YES];
}
Copy the code
/** Frame 2016-03-28 09:41:27.498 20160525-QQInterface [842:16465] NSConcreteNotification 0x7b274c00 {name = UIKeyboardDidChangeFrameNotification; userInfo = { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 253}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 606.5}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 353.5}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 253}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 227}, {320, 253}}"; UIKeyboardIsLocalUserInfoKey = 1; }} * /
/** Close the keyboard frame information */
2016- 03- 28 09:41:30.775 20160525-QQinterface[842:16465] -[ViewController scrollViewWillBeginDragging:]
2016- 03- 28 09:41:31.287 20160525-QQinterface[842:16465] NSConcreteNotification 0x7b21cae0 {name = UIKeyboardDidChangeFrameNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 253}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160} 353.5";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160} 606.5";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 227}, {320, 253}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 480}, {320, 253}}";
UIKeyboardIsLocalUserInfoKey = 1;
}}
Copy the code
Handling keyboard attributes: who is responsible for evoking the keyboard, and who is responsible for modifying keyboard attribute information
UIKeyboardWillChangeFrameNotification object:nil];
//2. Handle textFieldView input controls
self.textFieldView.leftView = [[UIView alloc]initWithFrame:CGRectMake(0.0.8.0)];
self.textFieldView.leftViewMode = UITextFieldViewModeWhileEditing;
//3. Keyboard information processing principle: who triggers the keyboard pop-up, who is responsible for processing the keyboard attributes
[self.textFieldView setReturnKeyType:UIReturnKeySend];
[self.textFieldView setEnablesReturnKeyAutomatically:YES];// indicating whether the Return key is automatically enabled when the user is entering text
Copy the code
2.2 Summary of experience on control not displayed:
- The frame of the parent control
- The frame of the current control
- The hidden property of the current control
- Alpha <= 0.01 for the current control
2.3 UIDevice
The UIDevice class enhances a singleton that represents the device; It allows you to obtain device information (batteryLevel, batteryState, Model, systemVersion)
• The single particle object is available via [UIDevice currentDevice]
2.4 Introduction to ARC
ARC is a compiler feature, not an IOS runtime feature, and it is not similar to garbage Collector (GC) in other languages
#import "Person.h"
@implementation Person
/** ARC is a compiler feature, not an IOS runtime feature, and it is not similar to the garbage collector (GC) rules of other languages: As long as there is a single variable pointing to the object, the object remains in memory -- all instance variables and local variables are strong Pointers by default, because they keep the object alive. 2)OC has strong and weak references. Weak pointer variables can still point to an object, but are not owned by the object. The weak pointer is mainly used in the parent-child relationship. That is, the father has a strong pointer for the son, and the son needs to use the weak pointer to point to the father. Typical examples: Your ViewControl has a UITableView via the strong pointer (self.view). The dataSource and delegate of the UITableView are weak Pointers. Null_resettable, nonatomic,strong) UIView * View; @property (nonatomic, weak, nullable) id
delegate; 3) In ARC (a static analysis tool for code) Dealloc is mainly used for debugging to determine when objects are released. Can be used to manage some resources, *** an implementation of dealloc, Do not invoke the superclass's implementation; do not invoke the superclass's implementation; do not invoke the superclass's implementation 4) In ARC, associations between objects are considered, that is, which objects that object owns. Whenever you create an object, consider who should own it and how long the object should live. If you're using Core Foundation, malloc (), free (), you still need to manually manage */
- (void) dealloc{
NSLog(@"Person %@ freed %s".self.name,__FUNCTION__);
}
@end
Copy the code
2.5 Debugging Techniques
- Use of the Po keyword – Prints memory objects
(lldb) po notification
NSConcreteNotification 0x10010eb20 {name = zhengaiwang; object = <HSMatchmakingCompany: 0x100206170>; userInfo = {
info = "...";
title = "\U65b0\U6765\U4e86\U4e00\U6279\U7f8e\U5973";
}}
Copy the code
- Clear cell color
[cell setBackgroundColor:[UIColor clearColor]];
[self.tableView setBackgroundColor:[UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:1]].Copy the code
see also
IOS solves the problem of blurred images after compression
Blog.csdn.net/z929118967/…
🍅 Contact author: iOS Reverse (public number: iosrev)
🍅 Author profile: CSDN blog expert certification 🏆 international Top 50, Huawei Cloud enjoy expert certification 🏆, iOS reverse public number master
🍅 Resume template, technical assistance. Pay attention to me, all for you.