[objc]view plain
copy
"font-family: arial, helvetica, sans-serif; background-color: rgb(255, 255, 255);"
>具體先看效果圖
直接上**:
[objc]view plain
copy
@inte***ce
ccradarview : uiview
/*當前雷達中心縮圖*/
@property
(nonatomic
,strong
)uiimage
* thumbnailimage;
-(instancetype)initwithframe:(cgrect)frameandthumbnail
:(nsstring
*)thumbnailurl;
@end
[objc]view plain
copy
@inte***ce
ccradarview()
@property
(nonatomic
,weak)
calayer
* animationlayer;
@end
@implementation
ccradarview
[objc]view plain
copy
"code"[objc]view plainclass
="objc"
>"code"
class
="objc"
>-(instancetype)initwithframe:(cgrect)frame
andthumbnail
:(nsstring
*)thumbnailurl
return
self
; }
copy
- (void
)drawrect:(cgrect)rect
[self
.layer
addsublayer
:self
.animationlayer
];
//以下部分為雷達中心的使用者縮圖。雷達圈圈也是從該圖中心發出。
calayer
* thumbnaillayer = [[calayer
alloc
]init];
thumbnaillayer.backgroundcolor
= [uicolor
whitecolor
].cgcolor
; cgrect thumbnailrect = cgrectmake(0, 0
, 46,
46);
thumbnailrect.origin
.x= (rect
.size
.width
- thumbnailrect
.size
.width)/2
.0;
thumbnailrect.origin
.y= (rect
.size
.height
- thumbnailrect
.size
.height)/2
.0;
thumbnaillayer.frame
= thumbnailrect;
thumbnaillayer.cornerradius= 2
3.0; thumbnaillayer.borderwidth= 1
.0;
thumbnaillayer.maskstobounds
= yes
; thumbnaillayer.bordercolor
= [uicolor
whitecolor
].cgcolor
; uiimage
* thumbnail =
self
.thumbnailimage
; thumbnaillayer.contents
= (id
)thumbnail
.cgimage
; [self
.layer
addsublayer
:thumbnaillayer];
}
[objc]view plain
copy
"code"[objc]view plainclass
="objc"
>
// 動畫因應用程式進入後台後會停止。故避免在重新啟用程式時出現卡死假象。
- (void
)resume
} -(void
)dealloc
copy
"code""code"class
="objc"
>其中有個uicolor (category)
[objc]view plain
copy
class
="objc"
>"code"
class
="objc"
>+ (
uicolor
*)colorwithhexrgb:(
nsstring
*)rbg
if([cstring
hasprefix
:@"0x"
])
if([cstring
hasprefix
:@"#"
])
if(cstring
.length
!= 6
)
nsrange range = nsmakerange(0, 2
);
nsstring
*rstring = [cstring
substringwithrange
:range];
range.location= 2
; nsstring
*gstring = [cstring
substringwithrange
:range];
range.location= 4
; nsstring
*bstring = [cstring
substringwithrange
:range];
unsigned int
red =
0;
unsigned int
green=
0;
unsigned int
blue =
0;
[[nsscannerscannerwithstring
:rstring]
scanhexint
:&red];
[[nsscannerscannerwithstring
:gstring]
scanhexint
:&green];
[[nsscannerscannerwithstring
:bstring]
scanhexint
:&blue];
return
[uicolor
colorwithred
:red/25
5.0green
:green/25
5.0blue
:blue/25
5.0alpha:1
.0];
}
@end
iOS 雷達掃瞄效果 實現
1 rotationanimation.removedoncompletion no 23 rotationanimation.fillmode kcafillmodeforwards fillmode的作用就是決定當前物件過了非active時間段的行為.比如動畫開始之前,動畫結束之後。如果是乙個動...
利用html和css做 雷達 效果
外層套乙個div,用於作為參考定位。中間層作為雷達旋轉的容器,因為雷達效果是以螢幕中間 這裡設定為外層div的中間 進行360度旋轉,因此旋轉的是這個div。內層用於實現雷達的樣式,需要漸變,但是單純的漸變和雷達效果有區別,因此還需要旋轉,並且被父級div遮罩住部分,才能實現出雷達所表現的樣式。la...
iOS 動畫效果
最普通動畫 開始動畫 uiview beginanimations nil context nil 設定動畫持續時間 uiview setanimationduration 2 動畫的內容 frame.origin.x 150 img setframe frame 動畫結束 uiview commi...