小编use*_*826的帖子

UITextView contentInset 不起作用

我在 UITextView 中显示文本。我需要对文本应用一些填充。当我使用最高位置的价值时,它就起作用了。如果我将价值用于其他职位,则它不起作用。

 txtt_bgImage     = [UIImage imageNamed:@"txtt_bg_ipad.png"];
                  txtt_bgImageView = [[UIImageView alloc] initWithImage:txtt_bgImage];

          txtt=[[UITextView alloc]initWithFrame:CGRectMake(170, 300, 400, 250)];

          txtt.text=productDescription;



                  [txtt  setFont: [UIFont fontWithName:@"verdana" size:15]];

                  txtt.textColor=[UIColor whiteColor];

                  [txtt setBackgroundColor:[UIColor clearColor]];


                  txtt.contentInset = UIEdgeInsetsMake(15,0,0,0);

                //  [txtt  setTextContainerInset:UIEdgeInsetsMake(7, 7, 0, 0)];

                  txtt_bgImageView.frame=CGRectMake(170, 300, 400, 250);


                  [self.view addSubview:txtt_bgImageView];

                  txtt.editable=NO;

          NSLog(@"text is %@",txtt.text);

                   object.object_screentext = txtt;

          [self.view addSubview:txtt];
Run Code Online (Sandbox Code Playgroud)

objective-c uitextview ios ios6 uiedgeinsets

4
推荐指数
1
解决办法
5114
查看次数

删除UIButton的手势

UIGestureRecognizer用于平移,旋转,捏.但我正在申请整个观点.我需要删除子视图以外的按钮的手势.但是,当我使用泛按钮也影响.如何限制按钮从self.view移动.我使用下面的代码UIPanGestureRecognizer.

UIPanGestureRecognizer *dbpan = [[UIPanGestureRecognizer alloc] initWithTarget:self
                                                                        action:@selector(ondbPan:)];

[self.view addGestureRecognizer:dbpan];

[closeButton removeGestureRecognizer:dbpan];
Run Code Online (Sandbox Code Playgroud)

泛:

- (void)ondbPan:(UIPanGestureRecognizer *)gesture
{
    if ((gesture.state == UIGestureRecognizerStateChanged) ||
        (gesture.state == UIGestureRecognizerStateEnded)) {


        CGPoint offset = [gesture translationInView:self.view];

        CGPoint center = gesture.view.center;
        center.x += offset.x;
        center.y += offset.y;
        gesture.view.center = center;

        [gesture setTranslation:CGPointZero inView:self.view];

    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton uigesturerecognizer ios uipangesturerecognizer

1
推荐指数
1
解决办法
1174
查看次数