这是我在我的中添加段落间距的代码UITextView
,但是如何删除它?
试过了paragraphStyle.paragraphSpacing = 0;
,但它没有改变。
- (IBAction)addParagraphSpacing:(id)sender {
UITextView *selectedtextfield = (UITextView *)[self.view viewWithTag:1];
// get font name & pointsize
UIFont *currentfontname = [selectedtextfield font];
NSString *currentFontname = [currentfontname fontName];
UIFont *currentfontsize = [selectedtextfield font];
CGFloat currentfontSize = [currentfontsize pointSize];
CGFloat NewParagraphSpacing = currentfontSize / 2;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.paragraphSpacing = NewParagraphSpacing;
NSString *string = selectedtextfield.text;
UIFont *currenttypo = [UIFont fontWithName:@"Arial" size:currentfontSize]; // ?
NSDictionary *attributtes = @{ NSParagraphStyleAttributeName : paragraphStyle,};
selectedtextfield.attributedText = [[NSAttributedString alloc] initWithString:string attributes:attributtes];
selectedtextfield.font = currenttypo;
selectedtextfield.font = [UIFont fontWithName:currentFontname size:currentfontSize];
selectedtextfield.textAlignment = NSTextAlignmentCenter;
}