I want to add text on image. User can adjust text anywhere on that image. I am using UIRotationGestureRecognizer, UIPanGestureRecognizer, UIPinchGestureRecognizer. But the problem is the text moves all over in my view when I do gestures. I want it to move, zoom, rotate on just that imageview. Please Help. for that I have taken one UIView in main view. Then UIImageView inside that subview and UITextView.
0
votes
1 Answers
0
votes
[self buildAgreeTextViewFromString:NSLocalizedString(str,@"\UserName\xgdfg\" #<ts>#") forRow:indexPath.row];
- (void)buildAgreeTextViewFromString:(NSString *)localizedString forRow:(long)row
{
// 1. Split the localized string on the # sign:
NSArray *localizedStringPieces = [localizedString componentsSeparatedByString:@"#"];
// 2. Loop through all the pieces:
NSUInteger msgChunkCount = localizedStringPieces ? localizedStringPieces.count : 0;
CGPoint wordLocation = CGPointMake(0.0, 0.0);
for (NSUInteger i = 0; i < msgChunkCount; i++)
{
NSString *chunk = [localizedStringPieces objectAtIndex:i];
if ([chunk isEqualToString:@""])
{
continue; // skip this loop if the chunk is empty
}
// 3. Determine what type of word this is:
BOOL isTermsOfServiceLink = [chunk hasPrefix:@"<ts>"];
BOOL isPrivacyPolicyLink = [chunk hasPrefix:@"<pp>"];
BOOL isLink = (BOOL)(isTermsOfServiceLink || isPrivacyPolicyLink);
// 4. Create label, styling dependent on whether it's a link:
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont fontWithName:@"OpenSans" size:13.0F];
// label.font = [UIFont systemFontOfSize:11.0f];
label.text = chunk;
label.textColor = [UIColor yellowColor];
label.userInteractionEnabled = isLink;
label.backgroundColor = [UIColor clearColor];
label.tag = row;
if (isLink)
{
//label.textColor = [UIColor blueColor];
//[self.view setBackgroundColor: [self colorWithHexString:@"FFFFFF"]];
label.textColor = UIColorFromRGB(text1_color_hexcode);
//1D89FF
//label.highlightedTextColor = [UIColor yellowColor];
// 5. Set tap gesture for this clickable text:
SEL selectorAction = isTermsOfServiceLink ? @selector(tapUserName:) : @selector(tapPost:);
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:selectorAction];
[label addGestureRecognizer:tapGesture];
tapGesture.numberOfTapsRequired = 1;
tapGesture.delegate = self;
// Trim the markup characters from the label:
if (isTermsOfServiceLink)
label.text = [label.text stringByReplacingOccurrencesOfString:@"<ts>" withString:@""];
if (isPrivacyPolicyLink)
label.text = [label.text stringByReplacingOccurrencesOfString:@"<pp>" withString:@""];
}
else
{
label.textColor = [UIColor darkGrayColor];
}
[label sizeToFit];
if (cell.notificationTxt_view.frame.size.width < wordLocation.x + label.bounds.size.width)
{
wordLocation.x = 0.0; // move this word all the way to the left...
wordLocation.y += label.frame.size.height; // ...on the next line
NSRange startingWhiteSpaceRange = [label.text rangeOfString:@"^\\s*"
options:NSRegularExpressionSearch];
if (startingWhiteSpaceRange.location == 0)
{
label.text = [label.text stringByReplacingCharactersInRange:startingWhiteSpaceRange withString:@""];
[label sizeToFit];
}
}
//CGFloat y = (cell.notificationTxt_view.frame.size.height - label.frame.size.height)/2;
label.frame = CGRectMake(wordLocation.x,
wordLocation.y,
label.frame.size.width,
label.frame.size.height);
[cell.notificationTxt_view addSubview:label];
wordLocation.x += label.frame.size.width;
}
NSLog(@"%ld",row);
if(row==[notificationArray count]-1)
{
chekScrolling=NO;
}
}