2016-08-05 6 views
0
- (void)loadView { 

// Create a GMSCameraPosition that tells the map to display the 
// coordinate -33.86,151.20 at zoom level 6. 
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.551927 
                 longitude:-77.456292 
                  zoom:18]; 
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(37.551709, -77.456510); 
GMSMarker *marker = [GMSMarker markerWithPosition:position]; 
marker.title = @"Hi"; 
marker.map = mapView; 
mapView.settings.myLocationButton = YES; 
mapView.myLocationEnabled = YES; 
self.view = mapView; 

GMSMutablePath *path = [GMSMutablePath path]; 
[path addCoordinate:CLLocationCoordinate2DMake(37.552243, -77.457415)]; 
[path addCoordinate:CLLocationCoordinate2DMake(37.551054, -77.455443)]; 

GMSPolyline *polyline = [GMSPolyline polylineWithPath:path]; 
int x = 0; 
if ((x = 1)){ 
    polyline.spans = @[[GMSStyleSpan spanWithColor:[UIColor redColor]]]; 
} 
else polyline.spans = @[[GMSStyleSpan spanWithColor:[UIColor greenColor]]]; 
polyline.strokeWidth = 10.f; 
polyline.map = mapView;} 

조건에 따라이 폴리 라인의 색상을 변경하려고합니다. 나는 Xcode를 처음 사용하기 때문에 if 문을 시도했지만 어떤 이유로 작동하지 않는다. 어떤 아이디어라도 감사 할 것입니다!폴리 라인 변경 조건부로

답변

0

과제와 비교 ​​연산자를 혼합했습니다.

= -> 새 값을 지정
== -> 확인 왼쪽과 오른쪽 값은 당신을 위해

불행하게도 같은 경우는 뭔가 다른 것을 의미하지만, 그것은 여전히 ​​유효 "조건"문입니다.

if (x = 1) - x1

같다> 경우 - 할당이 성공하면>
if (x == 1) ( x의 값이 고려 될 즉 true)