首页 文章

在ios中的图像上的文本的手势

提问于
浏览
0

我想在图像上添加文字 . 用户可以在该图像的任何位置调整文本 . 我正在使用UIRotationGestureRecognizer,UIPanGestureRecognizer,UIPinchGestureRecognizer . 但问题是当我做手势时,文字会在我的视野中移动 . 我想让它移动,缩放,旋转那个imageview . 请帮忙 . 因为我在主视图中采用了一个UIView . 然后在那个子视图和UITextView里面的UIImageView .

1 回答

  • 0
    [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;
        }
    }
    

相关问题