我在cocos2d的CCLayer中有一个UITextView * textView。文本在水平和垂直方向上滚动。但是,我需要它只能垂直滚动和弹跳。 如何以编程方式停止水平滚动?
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(100,200, windowSize.height/2,windowSize.width/2)];
textView.backgroundColor = [UIColor clearColor];
textView.text = @"I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy";
[textView setEditable:NO];
textView.font = [UIFont fontWithName:@"Helvetica" size:24.0f];
CGPoint location = CGPointMake(200, 160);
textView.showsHorizontalScrollIndicator = NO;
//textView.bounces = NO;
//textView.alwaysBounceVertical = YES;
textView.center = location;
textView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS( 90.0f ));
我该怎么做才能停止水平滚动?
谢谢。
答案 0 :(得分:1)
我不知道这是否是一个好的解决方案。但它对我有用。我在这里发帖,以便任何人都可以纠正它。
textView = [[UITextView alloc] initWithFrame:CGRectMake(100,200,200 ,200)];
textView.backgroundColor = [UIColor clearColor];
NSLog(@"description: %@", enemyDescription);
textView.text = enemyDescription;
[textView setEditable:NO];
textView.font = [UIFont fontWithName:@"Helvetica" size:14.0f];
CGPoint location = CGPointMake(200, 160);
textView.showsHorizontalScrollIndicator = NO;
textView.alwaysBounceVertical = YES;
textView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS( 90.0f ));
[[[CCDirector sharedDirector]openGLView]addSubview:textView];
它对我有用。它只上下滚动,也可以上下反弹。
谢谢。