点击时更改自定义InfoWindow的文本颜色

时间:2016-06-23 09:33:10

标签: objective-c uiview uibezierpath infowindow

我将自定义视图作为MarkerInfoWindow返回。在此视图中,我添加了一个显示文本的按钮,并添加了一个名为三角视图的视图,该视图在矩形Uivew下创建三角形,我将返回InfoWindow.Everthing很好,为我工作,除非我想在用户选择或点击信息窗口时显示选择效果(用户应该知道他点击了信息窗口)

  - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
    {
        CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(self->_longpressLatitude.doubleValue, self->_longpresssLongitude.doubleValue);
        CGPoint point = [_googleMapView.projection pointForCoordinate:coordinate];

        //Creating a view which contains Button, triangle view
        self->_View =[[UIView alloc]initWithFrame:CGRectMake(point.x, point.y , 180, 60.4)];
        [self->_View setTag:101];
        self->_View.layer.cornerRadius=10;

        //UIButton with text "Sample";
        UIButton *SampleButton=[UIButton buttonWithType:UIButtonTypeSystem];
        SampleButton.frame = CGRectMake(3, 3 ,174, 41.4f);

        [SampleButton setBackgroundColor:[UIColor whiteColor]];
        [SampleButton setTitle:@"Sample" forState:UIControlStateNormal];
        [SampleButton addTarget:self action:@selector(onclick:) forControlEvents:UIControlEventTouchUpInside];

        [SampleButton setTitleColor:[UIColor colorWithRed:0.29 green:0.56 blue:0.89 alpha:1.0] forState:UIControlStateNormal];
        [SampleButton setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
        SampleButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14];

        [[SampleButton layer] setBorderWidth:0.1f];
        [[SampleButton layer] setBorderColor:[UIColor lightGrayColor].CGColor];

        SampleButton.layer.cornerRadius = 8;
        [self->_createView addSubview:SampleButton];       

        //Triangular part below the SampleButton
        UIView *triangleView = [[UIView alloc] initWithFrame:CGRectMake(73.0f,44.4f, 28.0f ,11.4f)];
        UIBezierPath* trianglePath = [UIBezierPath bezierPath];
        [trianglePath moveToPoint:CGPointMake(0, 0)];

        [trianglePath addQuadCurveToPoint:CGPointMake(3.0f, 3.0f) controlPoint:CGPointMake(1.5f, 0.0f)];

        [trianglePath addLineToPoint:CGPointMake(9.7f,12.0f)];

        [trianglePath addQuadCurveToPoint:CGPointMake(18.3f,12.0f) controlPoint:CGPointMake(14.0f, 20.0f)];

        [trianglePath addLineToPoint:CGPointMake(25.0f, 3.0f)];

        [trianglePath addQuadCurveToPoint:CGPointMake(28.0, 0.0f) controlPoint:CGPointMake(26.8f, 0.0f)];

        CAShapeLayer *triangleMaskLayer = [CAShapeLayer layer];
        [triangleMaskLayer setPath:trianglePath.CGPath];

        triangleMaskLayer.lineWidth = 0.1f;
        triangleMaskLayer.fillColor = [[UIColor whiteColor] CGColor];

        UILabel *linelbl = [[UILabel alloc]initWithFrame:CGRectMake(73.0, 43.4f, 28, 1.2f)];
        linelbl.backgroundColor = [UIColor whiteColor];

        [triangleView.layer addSublayer:triangleMaskLayer];
        [self->_View addSubview:triangleView];
        [self->_View addSubview:linelbl];
        [self->_View setBackgroundColor:[UIColor clearColor]];
        return self->_View;

    }

0 个答案:

没有答案
相关问题