Can I change the size of UIActivityIndicator?
The size is fixed by the style. It's a standardized interface element so the API doesn't like to fiddle with it.
However, you probably could do a scaling transform on it. Not sure how that would affect it visually, however.
Just from a UI design perspective, its usually better to leave these common standardized elements alone. User have been taught that certain elements appear in a certain size and that they mean specific things. Altering the standard appearance alters the interface grammar and confuses the user.
How to increase the size of the activity indicator
You can try setting loadingIndicator.transform = CGAffineTransform.init(scaleX: 2, y: 2)
Unable to set / increase the size of UIActivityindicator view
What i did to change the ActivityIndicator
size in app is:
Just Apply the Transform on your activity indicator and Rescale it.
Here is the code
UIActivityIndicatorView* mySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
mySpinner.transform = CGAffineTransformMakeScale(1.5, 1.5);
mySpinner.color=[UIColor blueColor];
mySpinner.center =self.view.center;
mySpinner.hidesWhenStopped = YES;
[self.view addSubview:mySpinner];
My activityIndicator don't resize
Since you have written the above snippet without NSLayoutConstraint
, the shortest solution would be to respond to:
- viewWillTransitionToSize:withTransitionCoordinator
Storyboard solution
A more elegant solution is to use Storyboard
+ Autolayout
and exactly 3 lines of code, 1 being optional:
func showActivityIndicator(uiView: UIView){
self.view.bringSubviewToFront(loadingView); // Only if covered
loadingView.hidden = false
activityIndicator.startAnimating()
}
You can move the round corners, colors and more to -viewDidLoad
.
loadingView.clipsToBounds = true
loadingView.layer.cornerRadius = 10
The size of the UIActivityIndicatorView by different version of software
That is completely up to you. If you want to support your application for iOS 4.2 and higher, use the arithmetic for 4.2 else go for 5.0.
Adjust UIActivityIndicatorView position in AlertView - Swift
Try following code:
var alert : UIAlertView = UIAlertView(title: "Loading...", message: nil , delegate: nil, cancelButtonTitle: nil)
var viewBack:UIView = UIView(frame: CGRectMake(83,0,100,100))
var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(50, 10, 37, 37))
loadingIndicator.center = viewBack.center
loadingIndicator.hidesWhenStopped = true
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
loadingIndicator.startAnimating();
viewBack.addSubview(loadingIndicator)
viewBack.center = self.view.center
alert.setValue(viewBack, forKey: "accessoryView")
loadingIndicator.startAnimating()
alert.show();
Is it possible to change an UIActivityIndicatorView color to black in iOS?
You can use the .color
property in order to change the UIActivityIndicatorView
color, e.g.:
// Objective-C
activityIndicator.color = [UIColor greenColor];
// Swift
activityIndicator.color = .green
Note that .color
is only available from iOS 5.
How to set a custom background view properly with UiActivityIndicator
There is no issue in either your auto layout setup nor the code you are trying.
The off-center issue actually seems to be an iOS bug when setting a custom color on a UIActivityIndicatorView
.
You can see this for yourself.
- Drag a basic
UIActivityIndicatorView
- Set a background color
Set it's style to "Large White"
Now set a color
This doesn't happen when the style is White
or Gray
Tested it in Xcode 9.3 Storyboard as well as Simulator with Debug > Color Blended layers - ON
Related Topics
Uitextview Content Size Different in iOS7
How to Add a Footer to a Uitableview in Storyboard
How to Use Avsamplebufferdisplaylayer in iOS 8 for Rtp H264 Streams with Gstreamer
Corelocation Heading Base on Back Camera (Augmented Reality)
Libmobilegestalt Mobilegestaltsupport.M:153 Mobilegestalt.C:550 Xcode Console
Getting Button Action:Uicollectionview Cell
iOS Find Color at Point Between Two Colors
Nsurlconnection Deprecated in iOS9
Passing Data from App Delegate to View Controller
Ios: Delete All Core Data Swift
iOS Autolayout to Center My View Between Two Views
How to Compare Ssl Certificates Using Afnetworking
Set Background Color of Active Tab Bar Item in Swift
Swift: Testing Optionals for Nil
Modulename-Swift.H File Not Found in Xcode8
Border Around Uitableview Section
Adding Click Event on Infowindow/Marker in Google Maps Sdk for Native iOS/Objective C