ios - Set Image inline with text to UITextView in Objective C -
i want add image inline text uitextview below screenshot
have try using nstextattachment
, nsattributedstring
put 1 line before & after image.
please me sort out.
you need use 'uibezierpath'
for example,
txtvhtmlstring.text = @“your long text…….”; imgview = [[uiimageview alloc] initwithframe:cgrectmake(120, 100, 152, 128)]; imgview.image = [uiimage imagenamed:@"smily.png"]; imgview.layer.cornerradius = 10; [txtvhtmlstring addsubview:imgview];
then don't forget update bezierpath in viewdidlayoutsubviews if text updated.
- (void)viewdidlayoutsubviews { uibezierpath *exclusionpath = [uibezierpath bezierpathwithrect:imgview.frame]; txtvhtmlstring.textcontainer.exclusionpaths = @[exclusionpath]; }
Comments
Post a Comment