@@ -30,7 +30,6 @@ var FloatingActionButton = (function (_super) {
3030 var button = MNFloatingActionButton . alloc ( ) . init ( ) ;
3131
3232 button . animationScale = 0.95 ;
33-
3433 this . _ios = button ;
3534
3635 }
@@ -111,29 +110,28 @@ function onIconPropertyChanged(data) {
111110 var icon = data . newValue ;
112111 var iconDrawable = null ;
113112
113+ //Kill the old Image, cocoapod doesn't support changing it yet
114+ var button = fab . ios . subviews [ 0 ] ;
115+ var oldBadImageView = button . subviews [ 0 ] ;
116+ oldBadImageView . removeFromSuperview ( ) ;
117+ var newImageView = null ;
118+
114119 if ( ImageSource . isFileOrResourcePath ( icon ) ) {
115120 iconDrawable = ImageSource . fromFileOrResource ( icon ) ;
116-
117- //Kill the old Image, cocoapod doesn't support changing it yet
118- var button = fab . ios . subviews [ 0 ] ;
119- var oldBadImageView = button . subviews [ 0 ] ;
120- oldBadImageView . removeFromSuperview ( ) ;
121- oldBadImageView . dealloc ( ) ;
122-
123- var newImageView = null ;
124-
121+
125122 //Set the new one
126123 if ( iconDrawable ) {
127124 newImageView = UIImageView . alloc ( ) . initWithImage ( iconDrawable . ios ) ;
128- } else {
129- //Default image
130- var defaultImage = ImageSource . fromBase64 ( "iVBORw0KGgoAAAANSUhEUgAAAJAAAACQAQAAAADPPd8VAAAAAnRSTlMAAHaTzTgAAAAqSURBVHgBY6AMjIJRYP9n0AuNCo0KMf+HgwPDTmgoRMeo0KgQRWAUjAIABsnZRR7bYyUAAAAASUVORK5CYII=" ) ;
131- newImageView = UIImageView . alloc ( ) . initWithImage ( defaultImage . ios ) ;
132- newImageView . frame = CGRectMake ( 0 , 0 , 40 , 40 ) ; //resize
133- }
134-
135- button . addSubview ( newImageView ) ;
125+ }
126+ } else {
127+ //Default image
128+ var defaultImage = ImageSource . fromBase64 ( "iVBORw0KGgoAAAANSUhEUgAAAJAAAACQAQAAAADPPd8VAAAAAnRSTlMAAHaTzTgAAAAqSURBVHgBY6AMjIJRYP9n0AuNCo0KMf+HgwPDTmgoRMeo0KgQRWAUjAIABsnZRR7bYyUAAAAASUVORK5CYII=" ) ;
129+ newImageView = UIImageView . alloc ( ) . initWithImage ( defaultImage . ios ) ;
130+ newImageView . frame = CGRectMake ( 0 , 0 , 40 , 40 ) ; //resize
131+
136132 }
133+
134+ button . addSubview ( newImageView ) ;
137135}
138136common . Fab . iconProperty . metadata . onSetNativeValue = onIconPropertyChanged ;
139137
@@ -143,4 +141,4 @@ function centerIcon(fab, newValue) {
143141
144142 imageView . center = CGPointMake ( newValue / 2 ,
145143 newValue / 2 ) ;
146- }
144+ }
0 commit comments