Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS中实现水平缩放视图?_Ios_Objective C_Uiscrollview_Horizontalscrollview - Fatal编程技术网

如何在iOS中实现水平缩放视图?

如何在iOS中实现水平缩放视图?,ios,objective-c,uiscrollview,horizontalscrollview,Ios,Objective C,Uiscrollview,Horizontalscrollview,我已经使用TSRDialScrollView库按照我代码中的设计要求来做了 但解决不了几个问题 参考以下链接: 我对代码做了一些更改 ->清除背景色 CGContextRef context = UIGraphicsGetCurrentContext(); [[UIColor clearColor] set]; CGContextFillRect(context, rect); 但它显示的是黑色 ->在视图反转后设置标签 - (void)drawLabelWithContext:(CGCon

我已经使用TSRDialScrollView库按照我代码中的设计要求来做了

但解决不了几个问题

参考以下链接:

我对代码做了一些更改

->清除背景色

CGContextRef context = UIGraphicsGetCurrentContext();
[[UIColor clearColor] set];
CGContextFillRect(context, rect);
但它显示的是黑色

->在视图反转后设置标签

- (void)drawLabelWithContext:(CGContextRef)context
                     atPoint:(CGPoint)point
                        text:(NSString *)text
                   fillColor:(UIColor *)fillColor
                 strokeColor:(UIColor *)strokeColor {


    // We want the label to be centered on the specified x value
    NSInteger label_y = ((point.y-100) - (boundingBox.width / 2));
}
->通过在代码中将小刻度和大刻度长度更改为负数,反转整个视图

- (void)drawTicksWithContext:(CGContextRef)context atX:(long)x
{
    CGPoint point = CGPointMake(x, self.frame.size.height);
    CGContextSetShadowWithColor(
                                context,
                                self.shadowOffset,
                                self.shadowBlur,
                                self.shadowColor.CGColor);

    if ([self isMajorTick:x]) {
        [self drawMajorTickWithContext:context
                               atPoint:point
                             withColor:self.majorTickColor
                                 width:self.majorTickWidth
                                length:-self.majorTickLength];
        // Draw the text
        //
        // 1) Take the existing position and subtract off the lead spacing
        // 2) Divide by the minor ticks to get the major number
        // 3) Add the minimum to get the current value
        //
        int value = (point.x - self.leading) / self.minorTickDistance + _minimum;

        NSString *text = [NSString stringWithFormat:@"%i", value];
        [self drawLabelWithContext:context
                           atPoint:point
                              text:text
                         fillColor:self.labelFillColor
                       strokeColor:self.labelStrokeColor];

    } else {

        CGContextSaveGState(context);
        [self drawMinorTickWithContext:context
                               atPoint:point
                             withColor:self.minorTickColor
                                 width:self.minorTickWidth
                                length:-self.minorTickLength];
        // Restore the context
        CGContextRestoreGState(context);
    }
} 
我希望按如下所示进行缩放

1) 通过调整偏移量,scrollview的视图应该位于中间(即,当滚动到最小值时,0的位置不在视图的中间)

2) 我希望背景颜色是清晰的颜色

3) 根据设计,如何将红色设置到要固定的中间线

< P > 4)如何在图像中层显示浅灰色?

我感谢你的帮助,并请建议如何实现这一点,真的我需要完成这项任务,这是非常需要的

提前谢谢

TRSDialView.m

文件:-

-(instancetype)initWithFrame:(CGRect)frame
add
self.opaque=NO

-(void)drawRect:(CGRect)rect
方法中,在
CGContextRef context=UIGraphicsGetCurrentContext()下面添加以下代码行代码

    // Fill the background
    CGContextSetFillColorWithColor(context, self.backgroundColor.CGColor);

   // CGContextFillRect(context, rect);
    CGContextClearRect(context, rect);
以上代码将清除背景色

要调整
偏移量
请将
宽度约束
添加到
序列图像板中的
TRSDialView

红线和灰色视图可以添加为
情节提要中的
子视图