Sometimes we want to know when we use ImageView to see whether the image displayed is placeholder or loaded or selected, but the Tag property can only be obtained but cannot be judged, of course, plus a few bool attributes may be done, but it will be somewhat complex, If you can assign a picture to the ImageView to add a marker, then the next time to determine whether the mark is placeholder on it, very simple.
uiimageview * picview = [[ uiimageview alloc] initWithFrame : Cgrectmake ( 10 90 50 50
picview. Layer. Cornerradius =3;
picview. userinteractionenabled =YES;
picview. Layer. Maskstobounds =YES;
picview. Image = [UIImageimagenamed:@ "Add_pic.png"];
[ picview image Setaccessibilityidentifier Span style= "Color:rgb (243,55,38); Font-family:menlo; Font-size:24px ">@" add " ";
The image "Add_pic.png" is labeled "Add", and when you change the image of Picview, the value of this property becomes null if you do not re-copy the Accessibilityidentifier property. Each image corresponds to an exclusive accessibilityidentifier, which allows us to identify the image.
Judge
if ([picview. Image. Accessibilityidentifierisequaltostring:@ "Add"]) {
[ self chooseimagefromablum: ^ (UIImage *image) {
Picview. image = image;
assign a new value to a new picture's accessibilityidentifier
[picview. Image setaccessibilityidentifier:@ "new"];
}];
}Else{
[self blowupimagewithpic:picview. Image ];
}
This makes it much easier to reduce the problem caused by too many bool variables.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use of the Accessibilityidentifier property of the image