IOS: common attributes, methods, and ios attributes
It is easy to forget the previous knowledge if you have not been in touch for a while. I wrote an article for months, but I forgot to pick it up.
0. macro definition
// Frame [UIScreen mainScreen]. bounds of the current mobile phone
1. UILabel
1-1) attributes of UILabel
// Content label. text // font label. font = [UIFont systemFontOfSize: fontSize]; // system label. font = [UIFont fontWithName: @ "Times New Roman" size: fontSize]; // Times New Roman body label. font = [UIFont italicSystemFontOfSize: fontSize]; // italic label. font = [UIFont boldSystemFontOfSize: fontSize]; // bold // default left-aligned label. textAlignment = NSTextAlignmentLeft; // wrap label. numberOfLines = 0; // default mode. The line feed ensures a complete word label. lineBreakMode = NSLineBreakByWordWrapping;
1. View
1-1) View attributes
// Rotate a view. transform = CGAffineTransformRotate (view. transform, M_PI); // zoom in width 1.5 times, zoom in 1.5 times, view. transform = CGAffineTransformScale (view. transform, 1.5, 1.5 );
1-2) View layer
// Set the rounded corner [view. layer setCornerRadius: 100]; // sets the border [view. layer setBorderWidth: 2.0]; // sets the border color [view. layer setBorderColor: [[UIColor grayColor] CGColor];
1-3) View Method
// Move the sub-View to the front [self. view bringSubviewToFront: view]; // All subviews NSArray * array = [self. view subviews]; // remove all subviews. Use for infor (UIView * view in array) {[view removeFromSuperview];}
2. navigation bar
// Launch a new view and use POP to return the view. Only the Controller can push the view. View cannot push [self. navigationController pushViewController: root animated: YES];
3. Table View
3-1) default cell attributes
// Content cell. textLabel. text = @ "xxx"; // detailed content cell. detailTextLabel. text = @ "xxx"; // image, png can have no suffix. jpg must be available. For the sake of rigor, write down the png file! Cell. imageView. image = [UIImage imageNamed: @ "xxx"]; // no gray cell is displayed when you click it. selectionStyle = UITableViewCellSelectionStyleNone; // cell on the right. accessoryType = UITableViewCellAccessoryDisclosureIndicator; // custom View on the right. The most common case is an arrow number, indicating loading more cells. accessoryView = view; // note that contentView is usually used for adding a Cell. It is a little different from adding a cell directly. contentView addSubview: view]; (here is the UILabel attribute) // unlimited rows = automatic line feed, cell. textLabel. numberOfLines = 0; // font style, size setting, cell. textLabel. font