I am writing an app that shows a list of BLE devices.
I'd like to show the signal strength graphically of each device like cellular signal bars instead of the actual number.
Does anyone know how to do this?
You may use an UIImageView
to render only a part of your image. Let's break it down:
UIImageView
to show your image on the screen;CGRect
to slice a portion your image and set it on your_image_view.layer.contentsRect
- Note that 1.0 = 100%;CGRect
;Example:
UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
CGRect frame = CGRectMake(/* x */ 0, /* y */ 0.5, /* width */ 1, /* height */ 0.25);
view.layer.contentsRect = frame;
view.image = [UIImage imageNamed:@"ble_bars.png"];
Reading the documentation about CGMakeRect and contentsRect should help you.