ios - How append string to a new line after setting exclusionPaths Rather than use NSTextAttachment? -
how can uitextview can append string new line below screenshot show?thanks me.
here code.
main code :
- (void)viewdidload { [super viewdidload]; nstextstorage *storage = [nstextstorage new]; nslayoutmanager *layoutmanager = [nslayoutmanager new]; [storage addlayoutmanager:layoutmanager]; nstextcontainer *textcontainer = [nstextcontainer new]; [layoutmanager addtextcontainer:textcontainer]; //setting exclusionpaths uiimage *image = [uiimage imagenamed:@"sample"]; cgrect arearect = cgrectmake(10, 50, 355, 180); uibezierpath *ovalpath = [uibezierpath bezierpathwithrect:arearect]; textcontainer.exclusionpaths = @[ovalpath]; //append text below image ,how do? nsattributedstring *text = [[nsattributedstring alloc]initwithstring:@"\ntest\ntet2\ntet2\ntet2\ntet2"]; [storage appendattributedstring:text]; uitextview *textview = [[uitextview alloc] initwithframe:cgrectmake(0, 0, 375, 600) textcontainer:textcontainer]; [self.view addsubview:textview]; // add image exclusionpaths area [textview addsubview:showimageview]; }
Comments
Post a Comment