zoukankan      html  css  js  c++  java
  • 第19月第17天 uitextview 文本垂直居中 uiimage中间不拉伸

    1.

    open class VericalCenteringScrollView: UIScrollView {
        override open var contentOffset: CGPoint {
            didSet {
                let contentSize = self.contentSize
                let scrollViewSize = self.bounds.size
                
                var contentOffset = self.contentOffset
                
                if contentSize.height < scrollViewSize.height
                {
                    contentOffset.y = -(scrollViewSize.height - contentSize.height) / 2.0;
                }
                
                super.contentOffset = contentOffset
            }
        }
    }

     2.

    + (UIImage *)createLoadingImage:(UIColor *)color size:(CGSize)size centerImage:(UIImage *)image2
    {
        /*生成loadingImage,中心为image2*/
        UIGraphicsBeginImageContext(size);
        
        // Draw image1
    //    [image1 drawInRect:CGRectMake(0, 0, size.width, size.height)];
        CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, rect);
        
        // Draw image2
        [image2 drawInRect:CGRectMake((size.width-image2.size.width)/2, (size.height-image2.size.height)/2, image2.size.width, image2.size.height)];
        
        UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
        return resultingImage;
    }
  • 相关阅读:
    java——对象学习笔记
    ORACLE中如何查看分区表信息
    postgresql相关系统表查询
    oracle系统表查询
    linux shell常用函数,ps
    文本文件合并
    nginx多版本PHP配置
    webuploader实现文件上传
    open abc.txt: The system cannot find the file specified
    PHP在线批量下载文件
  • 原文地址:https://www.cnblogs.com/javastart/p/8866445.html
Copyright © 2011-2022 走看看