ios - How to draw an image in a specific shape -
i ordinary image designer every new network call. design image must in shape this:
how can that? on android use path create such shape , use shader draw image in shape. don't find on ios?
thanks krivoblotsky. can use piece of code mask image:
- (uiimage*) _maskimage:(uiimage *) image withmask:(uiimage *) mask { cgimageref imagereference = image.cgimage; cgimageref maskreference = mask.cgimage; cgimageref imagemask = cgimagemaskcreate(cgimagegetwidth(maskreference), cgimagegetheight(maskreference), cgimagegetbitspercomponent(maskreference), cgimagegetbitsperpixel(maskreference), cgimagegetbytesperrow(maskreference), cgimagegetdataprovider(maskreference), null, yes ); cgimageref maskedreference = cgimagecreatewithmask(imagereference, imagemask); cgimagerelease(imagemask); uiimage *maskedimage = [uiimage imagewithcgimage:maskedreference]; cgimagerelease(maskedreference); return maskedimage; }
you need make sure image black , not sort of black because used transparency.
this tutorial , shows mask image:
http://jeroendeleeuw.com/post/33638733049/how-to-mask-images-with-core-graphics-in-ios
Comments
Post a Comment